Adding a AWS processed file already on S3 to a shrine object

Hi,

So, we’re using Shrine to store and manage videos. After uploading, we’re putting videos through Elastic MediaConvert to generate a bunch of difference versions of the video. The MediaConvert drops the versions/derivations wherever I want in either my shrine or non-shrine bucket – but the key is the file(s) are processed and on S3, so we don’t want to have to do anything other than possibly promote (move) them.

When looking at the Derivations plugin, as far as I can tell, it really only wants to work with an Attacher (obviously so any derivation goes through the standard lifecycle). But that’s a problem as we don’t want have to have to download the file(s) in order to reupload as part of the attach workflow.

What we ideally want is to be able to say to: Here is a derivation and have it added to the _data field as appropriate – something like model.shrine_field.add_derivation(S3_location, metadata: {}, without_copy: true) or model.shrine_field.add_derivation_without_copy(S3_location, metadata: {})…

Any help or direction would be appreciated.

The derivatives plugin can also add files to the *_data column that have already been uploaded, without any downloading and re-uploading, using Attacher#merge_derivatives.

uploaded_files = {
  foo: Shrine.uploaded_file(storage: :store, id: "path/to/file1"),
  bar: Shrine.uploaded_file(storage: :store, id: "path/to/file2"),
  ...
}

attacher.merge_derivatives(uploaded_files)

The id is the location on S3, minus any storage :prefix you might have. Let me know if this makes sense to you.

I understand now that this might not be super clear from the documentation, I’ll try to improve it.