How to set up Amazon S3, paperclip, and ENV variables

拥有回忆 提交于 2019-12-05 18:36:34

You can do one thing:

You can set this configuration in your development.rb or production.rb

config.paperclip_defaults = {
  :storage => :s3,
  :s3_credentials => {
    :bucket => ENV['S3_BUCKET_NAME'],
    :access_key_id => ENV['AWS_ACCESS_KEY_ID'],
    :secret_access_key => ENV['AWS_SECRET_ACCESS_KEY']
  }
}

And If you want to set this environment variables into local then use this:

sudo nano ~/.profile

Then add your variables over here

export S3_BUCKET_NAME="your bucket name"
export AWS_ACCESS_KEY_ID="your access key id"
export AWS_SECRET_ACCESS_KEY="your secret access key"

And then reload your ~/.profile with . ~/.profile

Check added variable with echo $S3_BUCKET_NAME

And for Heroku

You can set your variable like:

heroku config:set S3_BUCKET_NAME="your bucket name"
heroku config:set AWS_ACCESS_KEY_ID="your access key id"
heroku config:set AWS_SECRET_ACCESS_KEY="your secret access key"

Check that variables added or not in heroku with heroku config

For more detail you can refer form here.

Let me know if you need me more..

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!