【问题标题】:Paperclip - Aws::S3::Errors::PermanentRedirect回形针 - Aws::S3::Errors::PermanentRedirect
【发布时间】:2018-07-06 21:29:41
【问题描述】:

对此有很多问题,但似乎没有一个答案可以解决我的问题。我在 Rails 5.1 应用程序中使用 Paperclip,保存时出现 Aws::S3::Errors::PermanentRedirect The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint. 错误。仔细阅读,似乎常见的答案是确保在不使用 AWS 默认值的情况下正确设置区域。但是,尽管尝试了一些方法,但我无法解决它。

development.rb

config.paperclip_defaults = {
  storage: :s3,
  s3_credentials: {
    bucket: ENV.fetch('S3_BUCKET_NAME'),
    access_key_id: ENV.fetch('AWS_ACCESS_KEY_ID'),
    secret_access_key: ENV.fetch('AWS_SECRET_ACCESS_KEY'),
    s3_region: ENV.fetch('AWS_REGION'),
    s3_host_name: 'https://*mybucketname*.s3.eu-west-1.amazonaws.com',
  }
}

也试过s3_host_name: 'https://s3.eu-west-1.amazonaws.com'

我也尝试将其添加到: initializers/paperclip.rb

Paperclip::Attachment.default_options[:url] = ':s3_domain_url'
Paperclip::Attachment.default_options[:path] = '/:class/:attachment/:id_partition/:style/:filename'
Paperclip::Attachment.default_options[:s3_host_name] = 's3-eu-west-1.amazonaws.com'

不知道现在还可以尝试什么...

【问题讨论】:

    标签: ruby-on-rails amazon-s3 paperclip


    【解决方案1】:

    所以这是一个愚蠢的错误!

    我从 URL 中获取了区域:

    https://s3.console.aws.amazon.com/s3/buckets/mybucket/?region=eu-west-1&tab=overview
    

    当存储桶实际在欧盟(伦敦)创建时,eu-west-2

    我会把这个留在这里,以防有人犯这个错误。

    【讨论】:

      【解决方案2】:

      请检查您的 AWS_DEFAULT_REGION 环境。不是 AWS_REGION! "AWS_DEFAULT_REGION=" 对我有用。

      【讨论】:

        猜你喜欢
        • 2017-04-14
        • 2017-04-24
        • 2019-12-18
        • 2016-06-26
        • 1970-01-01
        • 2014-08-01
        • 2012-04-15
        • 2015-10-04
        • 1970-01-01
        相关资源
        最近更新 更多