【问题标题】:AWS::S3::Errors::PermanentRedirect on HerokuHeroku 上的 AWS::S3::Errors::PermanentRedirect
【发布时间】:2017-04-14 19:38:26
【问题描述】:

通过回形针上传文件后,我在 heroku 上遇到以下错误。

AWS::S3::Errors::PermanentRedirect(您尝试访问的存储桶 访问必须使用指定的端点进行寻址。请全部发送 未来对该端点的请求。)

这是我在模型中的设置

has_attached_file :profile_image,
 :styles => { :myrecipes => "260x180#"},
 :storage => :s3,
 :s3_region => 'us-west-1',
 :s3_credentials => "#{Rails.root}/config/amazon_s3.yml",
 :path => "/images/:id/:style.:extension",
 :url => ":s3_domain_url"

这是在 S3 上进行开发和存储图像,但在我尝试生产 (Heroku) 时出现错误。

【问题讨论】:

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


    【解决方案1】:

    要提供端点,您必须将其添加到您的回形针默认值中

    :s3_host_name => "s3-eu-west-1.amazonaws.com"
    

    或者你可以这样做

    s3_host_name: "s3-#{ENV['AWS_REGION']}.amazonaws.com"
    

    参考:paperclip issue

    【讨论】:

    • :url => ":s3_domain_url" 更改为 :url => ":s3_host_name"
    猜你喜欢
    • 2018-07-06
    • 2012-05-02
    • 2020-02-24
    • 1970-01-01
    • 2012-04-15
    • 2012-04-25
    • 1970-01-01
    • 2023-03-27
    • 2017-04-24
    相关资源
    最近更新 更多