[英]Rails: AWS S3 Access denied error with Paperclip upload
I am getting Aws::S3::Errors::AccessDenied Access Denied
whenever I tries to upload an image using paperclip and aws-sdk-s3.每当我尝试使用回形针和 aws-sdk-s3 上传图像时,我都会收到
Aws::S3::Errors::AccessDenied Access Denied
。
I have almost tried all the solution available on Internet.我几乎尝试了互联网上所有可用的解决方案。
I have tried configuring paperclip default option from here我已经尝试从这里配置回形针默认选项
Gems used gem "paperclip", git: "git://github.com/thoughtbot/paperclip.git" and gem 'aws-sdk-s3', '~> 1'
宝石使用
gem "paperclip", git: "git://github.com/thoughtbot/paperclip.git" and gem 'aws-sdk-s3', '~> 1'
My development.rb file configuration looks like我的development.rb文件配置看起来像
config.paperclip_defaults = {
storage: :s3,
path: '/:class/:attachment/:id_partition/:style/:filename',
s3_credentials: {
access_key_id: ENV['AWS_ACCESS_KEY_ID'],
secret_access_key: ENV['AWS_SECRET_ACCESS_KEY'],
s3_region: ENV['AWS_REGION'],
},
bucket: ENV['AWS_BUCKET'],
}
My model.rb file looks like我的model.rb文件看起来像
has_attached_file :photo
has_attached_file :image
has_attached_file :signature
My paperclip.rb file looks like我的paperclip.rb文件看起来像
Paperclip::Attachment.default_options[:s3_protocol] = 'http'
Paperclip::Attachment.default_options[:url] = ':s3_domain_url'
My aws.yml file looks like我的aws.yml文件看起来像
development:
access_key_id: MY_AWS_ACCESS_KEY_ID
secret_access_key: MY_AWS_SECRET_ACCESS_KEY
I am using gem 'figaro'
to save my environment variable for development environment.我正在使用
gem 'figaro'
来保存开发环境的环境变量。
May if someone can assists me would be appreciated.如果有人可以帮助我,将不胜感激。
The reason for me getting Aws::S3::Errors::AccessDenied Access Denied was my canned ACL properties were not configured properly.我得到 Aws::S3::Errors::AccessDenied Access Denied 的原因是我的预设 ACL 属性配置不正确。
Thanks, It might help someone.谢谢,它可能会帮助某人。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.