【问题标题】:Rails paperclip and amazon S3 'PermanentRedirect'Rails 回形针和亚马逊 S3 'PermanentRedirect'
【发布时间】:2014-08-01 21:27:15
【问题描述】:

我尝试使用 回形针 和 Amazon s3。我的存储桶在 EU (爱尔兰) 我收到了这个错误:

AWS::S3::Errors::PermanentRedirect in MyControllerController

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

这很烦人,我试图解决这个问题,但我想我会死的继续尝试。

这是我的代码:

s3.yml

access_key_id: *****
secret_access_key: ****
bucket: mybucketname
AWS_CALLING_FORMAT: s3-eu-west-1-amazonaws.com #not sure for this one

我在 10 分钟前设置了调用格式以进行最后一次测试,但没有任何变化

 config/initializers/paperclip.rb


Paperclip.options[:command_path] = "/usr/local/bin/"

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'

所以,我的模型:

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

最后

# in config/initializers/something.rb
 Paperclip.interpolates(:s3_eu_url) { |assets, style|
 "#{assets.s3_protocol}://s3-eu-west-1.amazonaws.com/#{assets.recipesappdev}  /#{assets.path(style).gsub(%r{^/}, "")}"
   }

所以,如果我忘记在此处放置文件,请随时告诉我。 有人有想法吗?

谢谢

编辑: 现在我有这个错误:

getaddrinfo: nodename nor servname provided, or not known

...真的不知道

【问题讨论】:

  • 你解决了吗?我也面临同样的问题。
  • 不,我没有成功解决这个问题。为了避免这个问题,我使用美国桶,没有欧盟

标签: ruby-on-rails heroku amazon-web-services amazon-s3 paperclip


【解决方案1】:

我相信您想在本文档中设置url: ":s3_domain_url":http://www.rubydoc.info/gems/paperclip/Paperclip/Storage/S3

这是我的配置。我不确定您是否需要路径或区域等所有内容:

# development.rb config.paperclip_defaults = { storage: :s3, url: ":s3_domain_url", path: ":class/:id/:attachment/:style.:extension", s3_region: "us-east-2", s3_credentials: { bucket: "whoops-proof-dev", access_key_id: "___", secret_access_key: "___", }, }

【讨论】:

    猜你喜欢
    • 2011-04-15
    • 2023-03-12
    • 2018-07-06
    • 1970-01-01
    • 2012-05-01
    • 2018-02-10
    • 1970-01-01
    • 2013-10-19
    • 2013-12-23
    相关资源
    最近更新 更多