【发布时间】:2015-03-30 11:46:28
【问题描述】:
我正在尝试使用 Amazon S3 将图像上传到我创建的存储桶中。但是,我不断收到一条错误消息 - Connection denied - connect(2) for "s3-website-us-west-1" 端口 443
我把它放在 config/environments/production.rb 文件中
config.paperclip_defaults = {
:storage => :s3,
:s3_credentials => {
:bucket => 'mybucketname', #ENV['S3_BUCKET_NAME'],
:access_key_id => 'myaccesskey'
:secret_access_key => 'mysecretkey'
}
这就是 initilizers paperclip.rb 文件中的内容
Paperclip::Attachment.default_options[:url] = 'mybucketname.com.s3-website-us-west-1.amazonaws.com'
Paperclip::Attachment.default_options[:path] = '/:class/:attachment/:id_partition/:style/:filename'
Paperclip::Attachment.default_options[:s3_host_name] = 's3-website-us-west-1'
我还将 IAM 用户设置为具有 AmazonS3FullAccess 和 AdministratorAccess 作为策略权限。谢谢,
【问题讨论】:
-
不要以为你想设置s3_host_name(虽然你可能想设置除了bucket之外的region)
-
当我没有设置 s3_host_name 时出现此错误 - “您尝试访问的存储桶必须使用指定的端点进行寻址。请将所有未来的请求发送到此端点。”我正在按照 heroku 网站的说明进行操作 - devcenter.heroku.com/articles/paperclip-s3 我也尝试添加区域,但得到了同样的错误。