简体   繁体   中英

Rails: Missing region error AWS heroku paperclip

I keep getting this error:

Aws::Errors::MissingRegionError (missing region; use :region option or export region name to ENV['AWS_REGION']):

my paperclip config looks like this:

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

tried to add :region ENV['AWS_REGION']

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

region in env is (when running heroku config)

AWS_REGION: us-east-1

tried to default config. created aws.rb in config/initializers

Aws.config.update({
region: 'us-east-1',
})

still doesn't work.

I got it working by performing the following:

  1. Add to config/environments.production.rb

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

  1. Set an additional heroku config by using: heroku config:set AWS_REGION=us-east-1

  2. Ensure your region lines up with the latest regions at: http://docs.aws.amazon.com/general/latest/gr/rande.html#opsworks_region

Hope that helps!

你应该尝试:s3_region not:region

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