store images locally for development s3 for production Rails Paperclip

前端 未结 3 1146
花落未央
花落未央 2021-02-18 15:24

I want to upload images on my local machine for development but store them on my Amazon S3 account for production.

upload.rb

if Rails.env.development?
           


        
3条回答
  •  自闭症患者
    2021-02-18 15:58

    Why not modify paperclip default options in production.rb?

    Add this to config/environments/production.rb:

    Paperclip::Attachment.default_options.merge!({
      :storage => :s3,
      :bucket => 'bucketname',
      :s3_credentials => {
        :access_key_id => ENV['S3_ACCESS_KEY'],
        :secret_access_key => ENV['S3_SECRET_KEY']
      }
    })
    

提交回复
热议问题