简体   繁体   中英

Paperclip S3 buckets, proc and environments

From reading the documentation I understand this might be doable, but I don't know how!

For the production environment I have three buckets (three models, three buckets) image-bucket, audio-bucket, pdf-bucket, but for the development environment, I want to have dev-image-bucket, dev-audio-bucket, dev-pdf-bucket.

How do I set the proc? Do I set up multiple configuration files, example code would be greatly appreciated.

No need for a proc. In your model:

has_attached_file :image,
                  :storage => :s3,
                  :s3_credentials => "#{RAILS_ROOT}/config/s3.yml",
                  :path => "whatever",
                  :bucket => "#{Rails.env}-image-bucket" 

不,这就是我想要的

:bucket => lambda { |photo| "#{(Rails.env.development? ? 'dev-' : '' )}feature-photos" }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM