Shrine

Upload_options plugin for dynamic options, but covering more than one storage

The way the upload_options plugin works now, you can register a block to supply dynamic options, but it’s per-storage, you register it with the storage name/key, eg:

plugin :upload_options, store: -> (io, options) do

Shrine has a lot of features to make your storages somewhat complicated; to let you have more than two storages going on at once, or even to have the storages by dynamic and unbounded. Features like dynamic storage, default storage with a block, or providing a proc as the value to the storage key in the derivatives plugin.

I’m using some of these, such that it’s challenging to register my block for each storage I want it to apply to, since they can be various and dynamic.

I’d like to register an upload_options block that will apply to any storage. While the upload_options plugin won’t currently do that, looking at the source… it would be pretty easy to add, perhaps you’d add a block with the key _all_. Which is pretty backwards compat.

But then, I’d also like my block to get an argument which tells it which storage is currently being used, so it can act dynamically on that too. That’s not hard to add in code, but has backwards compat concerns with changing the args passed to the block.

I wonder if I should try to contribute PR’s to add such features… or if I should just write my own local plugin, the upload_options plugin is so simple, i could just copy it locally and modify it to my needs.

Appreciate any advice from shrine maintainers if they’d appreciate a PR for some of these features, or if they think I’m better off just writing my own local plugin.