简体   繁体   English

使用回形针将 Heroku 上的图像上传到 Amazon s3 时定义了 Rails Access

[英]Rails Access Deined when uploading image on Heroku to Amazon s3 with paperclip

i try to upload image using amazon S3, but i have this error:我尝试使用亚马逊 S3 上传图片,但出现此错误:

AWS::S3::Errors::AccessDenied (Access Denied)

i used paperclip configuration:我使用回形针配置:

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

and i set a permission like this我设置了这样的权限

在此处输入图片说明

thank you !谢谢你 !

EDIT:编辑:

I created another bucket and it works, but now i have this error:我创建了另一个存储桶并且它可以工作,但现在出现此错误:

NoMethodError (undefined method `first' for nil:NilClass):

production.rb/development.rb生产.rb/development.rb

config.paperclip_defaults = {
    :storage => :s3,
    :s3_protocol => 'http',
    :s3_credentials => {
      :bucket => ENV['S3_BUCKET_NAME'],
      :access_key_id => ENV['AWS_ACCESS_KEY'],
      :secret_access_key => ENV['AWS_SECRET_ACCESS_KEY']
    }
  }

While Creating a bucket Select region as US-Standard and use above config.在创建存储桶时选择区域作为美国标准并使用上面的配置。 Try this it worked for me.Hopefully would work for you too.试试这个它对我有用。希望对你也有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM