使用paperclip gem在rails中使用AWS :: S3 :: Errors :: InvalidAccessKeyId

时间:2016-01-18 16:16:09

标签: ruby-on-rails heroku amazon-s3 paperclip aws-sdk

我在上传图片的注册时遇到此错误,但我已经在heroku配置中设置了我的AWS_SECRET_ACCESS_KEY和AWS_ACCESS_KEY_ID,并且三重检查了它们是否正确。

这是我在开发环境中的内容

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'],

  }
}

这是我的生产环境

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']
  }
}

这是我的aws.rb初始化程序(没有这两行,我得到了一个缺少的凭据错误)

AWS.config(
access_key_id: 'your_access_key',
secret_access_key: 'your_secret_access_key')

最后这是我的paperclip.rb初始化程序

# config/initializers/paperclip.rb
Paperclip::Attachment.default_options[:url] = ':s3_domain_url'
Paperclip::Attachment.default_options[:path] = '/:class/:attachment/:id_partition/:style/:filename'

有关为何我收到此无效访问密钥错误的任何建议?

AWS::S3::Errors::InvalidAccessKeyId in Devise::RegistrationsController#create
The AWS Access Key Id you provided does not exist in our records.

0 个答案:

没有答案