我正在使用Paperclip和AWS,并且可以成功上传到我的本地主机上。我遇到的问题是当我将应用程序上传到Heroku时,我得到:
AWS::S3::Errors::SignatureDoesNotMatch (The request signature we calculated does not match the signature you provided. Ch
熟悉您的密钥和签名方法。)
Locations.rb
has_attached_file :photo,
:styles => { :thumb => "150x150#", :medium => "200x200#", :small => "50x50"},
:path => ":attachment/:id/:style.:extension",
:s3_domain_url => "adsimgstore.s3.amazonaws.com",
:storage => :s3,
:s3_credentials => S3_CREDENTIALS,
:bucket => 'adsimgstore',
:s3_permissions => :public_read,
:convert_options => { :all => "-auto-orient" }
s3初始化
# initializers/s3.rb
if Rails.env == "production"
# set credentials from ENV hash
S3_CREDENTIALS = { :access_key_id => ENV['S3_KEY'], :secret_access_key => ENV['S3_SECRET'], :bucket => "adsimgstore"}
else
# get credentials from YML file
S3_CREDENTIALS = Rails.root.join("config/s3.yml")
end
我已经按照Heroku教程https://devcenter.heroku.com/articles/s3添加了所有键
有什么建议吗?
AWS::S3::Errors::SignatureDoesNotMatch (The request signature we calculated does not match the signature you provided. Ch
eck your key and signing method.):
2012-05-01T18:01:02+00:00 app[web.1]:
2012-05-01T18:01:02+00:00 app[web.1]: app/controllers/locations_controller.rb:76:in `block in update'
2012-05-01T18:01:02+00:00 app[web.1]: app/controllers/locations_controller.rb:75:in `update'
2012-05-01T18:01:02+00:00 app[web.1]:
答案 0 :(得分:1)
如果你遵循heroku教程,你的环境变量将是AWS_ACCESS_KEY_ID
和AWS_SECRET_ACCESS_KEY
。
运行heroku config
检查您的env变量。
:bucket
您将:bucket
选项放在S3_CREDENTIALS
- 哈希的initializers/s3.rb
文件中。 bucket-option不属于此处 - 您已经在has_attached_file
方法中设置了它。