[Proposal] Allow custom keys on ActiveStorage variants

Creating a variant for an attached entity does not allow a custom key, it automatically sets a key:

 attached_entity.variant(resize_to_limit: [200,200]).processed.url
=> "https://storage.googleapis.com/my_bucket/t6lgob4eat2lka1y4s27n3rjfwt3"

We could expose the process method and allow it to receive a key, so I can set the path where I want the variant to be placed.

1 Like

I’m really hoping that some work in general can be done on ActiveStorage to allow for deliberate naming and accessing of cloud stored items.

I use a screenshot API that really helpfully places output direct into S3 buckets. To turn this into an ActiveStorage object requires a bit a hackery where it should be so simple.

Is there a reason why adding custom keys is being managed so restrictive?

Another problem I’m thinking of is that the variant, although when using a processor like vips for images does not get the proper content-type appended. Thus, browsers are forced to download instead of initially displaying the image in the browser. => Forcing more traffic then necessary. On the scale this plugin is used this might be a huge amount. :thinking: At least when using the storage service in public mode.

I had issues with content-types too, same lack of control

1 Like