0

我正在使用 Paperclip 和 AWS,并且可以成功地让上传在我的本地主机上工作。我遇到的问题是当我将应用程序上传到 Heroku 时,我得到:

AWS::S3::Errors::SignatureDoesNotMatch (The request signature we calculated does not match the signature you provided. Ch

检查您的密钥和签名方法。)

地点.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]: 
4

1 回答 1

1
  • 检查您的环境变量是否匹配

如果您遵循 heroku 教程,您的环境变量将是AWS_ACCESS_KEY_IDand AWS_SECRET_ACCESS_KEY

运行heroku config以检查您的环境变量。

  • :bucket凭证中没有

您将:bucket选项放在文件的S3_CREDENTIALS-hash 中initializers/s3.rb。bucket-option 不属于这里 - 您已经在has_attached_file方法中设置了它。

于 2012-05-04T17:58:14.407 回答