-
Is there a recommended way to attach existing S3 blobs to ActiveRecord objects with shrine? We have lots of blobs being created from serverless functions and we've previously just used the SNS notification to redownload the blob and attach it again with ActiveStorage. We're moving to Shrine for a handful of other reasons, but interested if folks have a recommended solution for this particular problem. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
You can use photo.image_attacher.set Shrine.uploaded_file(storage: :store, id: "path/to/key")
photo.save You can use |
Beta Was this translation helpful? Give feedback.
You can use
Shrine::Attacher#set
and pass it an uploaded file object with the id being the S3 object key minus any storage prefix. For example:You can use
Shrine::Attacher#change
if you want to handle deletion of previous attachments or trigger validations.