Shrine Dynamic s3
Hi Chris,
I have a question I hope it's not out of scope for gorails but I'm having a hard time figuring it out.
I have a multi tenant site, each of the tenants add their own s3 credentials therefore any uploades that happen on their tenant site get's uploaded to their own s3 account.
The problem I have at the moment is that Shrine seems to only let me add s3 credentials in the initializer. I would like to add it to the model so that I can dynamically populate the s3 credentials depending on which tenant is being used at the time. Do you know anyway shrine can help me?
I managed to do this with paperclip but it came with other problems such as background processing etc.
That'd be a good question for Janko on the Shrine GitHub. I think that should be doable, but he would know how to do that best.
I believe you would just create the S3 storage instance each time you upload, rather than once in the initializer.
s3 = Shrine::Storage::S3.new(
bucket: "my-app", # required
region: "eu-west-1", # required
access_key_id: "abc",
secret_access_key: "xyz",
)
The above you would configure with the tenant's credentials and then you can probably call the upload method directly on this. He'll know best though!