Attach file directly to "store" storage? #640
-
Hello ! First of all, here is my Shrine config : Shrine.storages = {
cache: Shrine::Storage::GoogleCloudStorage.new(bucket: ENV['GCS_BUCKET'], prefix: 'uploads/cache'),
store: Shrine::Storage::GoogleCloudStorage.new(bucket: ENV['GCS_BUCKET'], prefix: 'uploads')
} For most of my records with attachments on it, I'm using the backgrounding plugin to upload the files to a google cloud bucket. However, there is one specific case where an "Attachment" record is created by the front-end, and my API should return a permanent URL of the file, but currently, it returns a URL to the cache storage which expire after the promotion is executed in the background. I cannot use direct upload in this case, because I need to create a db record, not only have a URL to the file on the bucket. Is it possible to do something like :
I hope I've been clear enough :) Thanks in advance for you help! 🙏 |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
You could create a special uploader and add: |
Beta Was this translation helpful? Give feedback.
-
You can bypass cache by using the attacher directly – https://shrinerb.com/docs/attacher#attaching-stored. photo.image_attacher.attach(file) # goes to store
photo.image_attacher.assign(file) # goes to cache (called by `photo.image = ...`) |
Beta Was this translation helpful? Give feedback.
You can bypass cache by using the attacher directly – https://shrinerb.com/docs/attacher#attaching-stored.