-
|
I realized I want to store my derivatives with some custom per-derivative metadata. Since derivatives are just shrine uploaded files and go through an uploader, they DO have metadata stored with them, just whatever metadata was created by the uploader. But I have some things that are artifacts of the creation process that I want to explicitly specify at the same time I'm specifying the binary data fro the derivative. Say, the version number of an external dependency used to create the derivative. What are the various ways or the best way I could specify metadata when saving a derivative? I'm currently using the Attacher.derivatives :thumbnails do |original|
{ large: ..., medium: ..., small: ... }
endBut in that API you provide a hash of keys and binary data, no way to add metadata? I thought of doing something complex involving storing metadata to add temporarily in the shrine context, and then having a custom uploader with over-ridden Thanks for any ideas! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
Sorry for the late reply. The most high-level method for generating derivatives The If you need per-derivative metadata, then I recommend not using an |
Beta Was this translation helpful? Give feedback.
Sorry for the late reply. The most high-level method for generating derivatives
Attacher#create_derivatives, which internally callsAttacher#process_derivatives(this calls yourAttacher.derivativesblock) and then callsAttacher#add_derivatives.The
Attacher#create_derivativesmethod doesn't support passing metadata, butAttacher#add_derivativesshould accept themetadata:keyword argument. So, if you just call these two methods separately, you should be good to go.If you need per-derivative metadata, then I recommend not using an
Attacher.derivativesblock but just generating derivatives manually.