markevans / dragonfly-s3_data_store

S3 data store for the Dragonfly ruby gem
MIT License
62 stars 58 forks source link

Possible to Have Different Buckets for Different Models? #20

Open rdetert opened 8 years ago

rdetert commented 8 years ago

I have all my image uploads going to s3.mydomain.com but for an attachment feature I'd like them to go in their own bucket attachments.mydomain.com

Is it possible to have different configurations for different models?

markevans commented 8 years ago

not currently, but you can assign e.g. model accessors to different dragonfly apps, each which have a differently configured s3 data store (as per http://markevans.github.io/dragonfly/models first couple of paragraphs). Does that suit the use case?

michaelkeenan commented 5 years ago

For anyone coming across this, as I did: this approach works, but it's easy to miss that you'll need to have a middleware line once for each bucket/app, as described here. For example:

Rails.application.middleware.use Dragonfly::Middleware
Rails.application.middleware.use Dragonfly::Middleware, :attachments