Shrine dynamic buckets

Hi all

(Thank you all for your gem and your support on the forums etc. (I’m happy to make a PR if required, to improve the documentation, or the code etc. if required):

Perhaps I will describe my problem for context:

  1. I have an active record model: project.rb

  2. I would ideally like each project to have its own bucket. So when someone uploads a file to a new project, then that project’s bucket will have to be created, and the files will need to be uploaded to that new bucket.

I am following the tutorial given here:

My question is: does Shrine automatically create a bucket (or can it programmatically create one), or will I have to manually create a bucket and then make sure it properly resolves dynamically using the dyamic storage and default storage plugins?

Thank you for your help!

rgds

Ben

Hi, Shrine doesn’t create the S3 bucket for you, the S3 storage assumes an already created bucket and credentials.

I would recommend having a separate table for storing created buckets and their credentials. The default_storage could then generate a storage name with the ID of the created bucket record, so that with dynamic_storage plugin you could then extract the ID from the name of the storage and retrieve the bucket record.

Here is a CLI I wrote for myself to help me reproduce issues with Shrine. Hopefully it can help with implementing programmatic bucket creation with bucket-specific credentials.

Thank you for your ideas!