I migrating from an existing S3 media system to Shrine, but I have ~130M records and I’m looking for ways to shrink the storage size of the metadata (and the best place to implement that). I can think of three ways to reduce the size of the hash:
- Replace hash keys with shorter forms (e.g. ‘metadata’ -> ‘md’, ‘derivates’ -> ‘dv’, etc.)
- Don’t store static mime types, e.g. if an attachment is always PNG don’t save the mime type
- Legacy S3 keys are organized by the model that contains them. Instead of calculating the full key and storing it, generate dynamic keys on the fly
#1 is easy enough, and can be implemented at the Mongoid field level
#2 is slightly trickier, can be handled by Mongoid but would it be better implemented in an Attachment or Uploader?
#3 is the hardest, as it requires the attachment have visibility into the model that it’s attached. I think this requires a custom Attacher for each legacy field, but I’m not sure how best to override the key generation.
Where is the best place to implement metadata transform logic like this? Are there any examples of people configuring Shrine to use legacy S3 keys?