Ruby Paperclip Amazon S3 Bucket Connection被拒绝 - 连接(2)for“s3-website-us-west-1”port 443

时间:2015-03-29 20:45:49

标签: ruby amazon-s3 paperclip

我正在尝试使用Amazon S3将图像上传到我创建的存储桶中。但是,我一直收到错误消息 - 连接被拒绝 - 连接(2)为“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作为策略权限。谢谢,

1 个答案:

答案 0 :(得分:3)

网站端点不支持https或上传 - 它们仅用于下载。您正在寻找REST端点,该端点应为s3-eu-west-1,假设它是您的存储桶位置,可能后跟.amazonaws.com,具体取决于该库所期望的内容。

http://docs.aws.amazon.com/AmazonS3/latest/dev/MakingRequests.html#RequestEndpoints

http://docs.aws.amazon.com/AmazonS3/latest/dev/WebsiteEndpoints.html