Skip to content

Attaching files to ActiveRecord objects from existing S3 blobs #688

Answered by janko
weilandia asked this question in Q&A
Discussion options

You must be logged in to vote

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:

photo.image_attacher.set Shrine.uploaded_file(storage: :store, id: "path/to/key")
photo.save

You can use Shrine::Attacher#change if you want to handle deletion of previous attachments or trigger validations.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by weilandia
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants