【问题标题】:permanentredirect s3 for unspecified endpoint未指定端点的永久重定向 s3
【发布时间】:2016-02-17 22:07:57
【问题描述】:

我正在尝试使用 s3,但遇到了权限问题(我认为)。

输出:

 AWS::S3::PermanentRedirect in CkeditorController#create

The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.

我正在使用 ckeditor。我的 Ckeditor::Picture 类包括:

  has_attached_file :data,
  :s3_credentials => "#{Rails.root}/config/s3.yml",
  :storage => :s3,
  :path => ":attachment/:id/:style.:extension"

  validates_attachment_size :data, :less_than=>2.megabytes

在 s3.yml 中,我得到了:

access_key_id: "key"
secret_access_key: "key"
bucket: "name"
AWS_CALLING_FORMAT: SUBDOMAIN

我错过了什么?提前谢谢!

【问题讨论】:

    标签: ruby-on-rails ruby-on-rails-3 amazon-s3 ckeditor


    【解决方案1】:

    使用paperclip 3.1.4 版,只需将s3_host_name 密钥添加到我的s3.yml 文件即可:

    development:
      bucket: 'bucket.name'
      access_key_id: 'xxx'
      secret_access_key: 'xxx'
      s3_host_name: 's3-eu-west-1.amazonaws.com'
    

    【讨论】:

      【解决方案2】:

      我想您的存储桶不在美国标准区域。您是否尝试将“AWS_CALLING_FORMAT: SUBDOMAIN”添加到您的 .yml 文件中?然后该请求应指向与您的存储桶区域对应的端点。

      【讨论】:

      • 感谢您的回答。我的桶在欧洲是的。我试图创建一个我们的存储桶,它完美地工作。但是,我尝试将您的 aws_calling_format i 放入其中,但它仍然无法正常工作。正如您在我更新的问题中看到的那样,我已经更新了我的 s3.yml。不是这样的吗?
      • 我猜你需要用适当的子域替换 SUBDOMAIN 例如:对于亚太地区:AWS_CALLING_FORMAT: s3-website-ap-southeast-1 但它仍然不适合我!
      【解决方案3】:

      我们可以像下面的代码一样使用默认端点。

      s3_credentials: {
           access_key_id: AWS_CONFIG['access_key_id'],
           secret_access_key: AWS_CONFIG['secret_access_key'],
           bucket: AWS_CONFIG['bucket'],
      },
      s3_host_name: 's3.amazonaws.com',
      s3_endpoint: 's3.amazonaws.com',
      storage: :s3,
      s3_headers:     { "Cache-Control" => "max-age=31557600" },
      s3_protocol:    "https",
      bucket:         AWS_CONFIG['bucket'],
      :url =>':s3_domain_url',
      :path => '/:class/:attachment/:id_partition/:style/:filename',
      default_url:   "/:class/:attachment/:id/:style/:basename.:extension",
      default_style: "medium"
      

      【讨论】:

        猜你喜欢
        • 2017-02-09
        • 2017-04-25
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-10-03
        • 1970-01-01
        • 2014-09-24
        相关资源
        最近更新 更多