【发布时间】: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