How to disable cache?

236 views
Skip to first unread message

erigia...@gmail.com

unread,
Jan 30, 2018, 5:37:03 PM1/30/18
to Shrine
Hello!
I'm using activerecord plugin and i want to upload my file right into store directly without caching.
How can i do that?

Janko Marohnić

unread,
Jan 30, 2018, 5:48:09 PM1/30/18
to erigia...@gmail.com, Shrine
You should be able to do that with the following:

  uploaded_file = photo.image_attacher.store!(file)
  photo.image_attacher.set(uploaded_file)

You currently still have to declare the :cache storage, otherwise Shrine will complain, but it won't be used. I think you could just do:

  Shrine.storages[:cache] = Shrine.storages[:store] = Shrine::Storage::YourStorage.new(...)

Kind regards,
Janko

--
You received this message because you are subscribed to the Google Groups "Shrine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ruby-shrine+unsubscribe@googlegroups.com.
To post to this group, send email to ruby-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ruby-shrine/7a00330b-3a0a-4bf9-8cd9-db757ac99746%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

deb...@nestready.ai

unread,
Sep 25, 2019, 5:13:08 PM9/25/19
to Shrine
Hi,

I'm looking to do this as well (upload directly to permanent storage), but I have defined versions (small, medium, large) in the uploader class.
When I use the code you suggested (photo.image_attacher.store!(file)), only the original image is uploaded.

What methods would I need to call to process and upload the versions as well, preferably without re-downloading the original image (ie, upload all 4 files at once)?

I'm using the Shrine 2.19.3, which is the latest version available on RubyGems.

Thank you,
Débora.

On Tuesday, January 30, 2018 at 5:48:09 PM UTC-5, Janko Marohnić wrote:
You should be able to do that with the following:

  uploaded_file = photo.image_attacher.store!(file)
  photo.image_attacher.set(uploaded_file)

You currently still have to declare the :cache storage, otherwise Shrine will complain, but it won't be used. I think you could just do:

  Shrine.storages[:cache] = Shrine.storages[:store] = Shrine::Storage::YourStorage.new(...)

Kind regards,
Janko
On Tue, Jan 30, 2018 at 11:37 PM, <erigia...@gmail.com> wrote:
Hello!
I'm using activerecord plugin and i want to upload my file right into store directly without caching.
How can i do that?

--
You received this message because you are subscribed to the Google Groups "Shrine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ruby-...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages