使用paperclip gem上传在开发中有效但不在生产中的图像。
Aws :: Errors :: MissingRegionError(缺少区域;使用:region选项或将区域名称导出到ENV [' AWS_REGION']):
heroku conifg
AWS_ACCESS_KEY_ID: <Aws Access Key Id>
**AWS_REGION: us-west-2**
AWS_SECRET_ACCESS_KEY: <Aws Secret Access Key>
DATABASE_URL: postgres://be4A6l7VOXXs@ec2-54-83-36-203.compute-1.amazonaws.com:5432/d2g7h0v5
LANG: en_US.UTF-8
RACK_ENV: production
RAILS_ENV: production
S3_BUCKET_NAME: <Bucket Name>
config.production文件
config.paperclip_defaults = {
:storage => :s3,
:region => ENV['AWS_REGION'],
:s3_credentials => {
:bucket => ENV['S3_BUCKET_NAME'],
:access_key_id => ENV['AWS_ACCESS_KEY_ID'],
:secret_access_key => ENV['AWS_SECRET_ACCESS_KEY']
}
}
的Gemfile
来源&#39; https://rubygems.org&#39;
ruby '2.0.0'
gem 'rails', '4.1.7'
gem 'sqlite3', group: :development
gem 'sass-rails', '~> 4.0.3'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'spring', group: :development
gem 'simple_form'
gem 'bootstrap-sass', '~> 3.3.5'
gem 'devise'
**gem 'paperclip', github: 'thoughtbot/paperclip'
**gem 'aws-sdk', '~> 2.1', '>= 2.1.31'****
gem 'rails_12factor', group: :production
gem 'pg', group: :production
更新了配置文件
config.paperclip_defaults = {
:storage => :s3,
:s3_region => ENV['AWS_REGION'],
:s3_credentials => {
:bucket => ENV['S3_BUCKET_NAME'],
:access_key_id => ENV['AWS_ACCESS_KEY_ID'],
:secret_access_key => ENV['AWS_SECRET_ACCESS_KEY']
}
}
答案 0 :(得分:1)
使用s3_region
,因此您的配置如下所示:
config.paperclip_defaults = {
:storage => :s3,
:region => ENV['AWS_REGION'],
:s3_region => ENV['AWS_REGION'],
:s3_credentials => {
:bucket => ENV['S3_BUCKET_NAME'],
:access_key_id => ENV['AWS_ACCESS_KEY_ID'],
:secret_access_key => ENV['AWS_SECRET_ACCESS_KEY']
}
}
我认为:region => ENV['AWS_REGION'],
不是必需的。