【问题标题】:Paperclip providing wrong URL when using S3使用 S3 时提供错误 URL 的回形针
【发布时间】:2018-04-09 09:52:44
【问题描述】:

正确的 url 是:http://s3.dvulgsolucoes.com.br/folder/filename.png,我得到这个 url:http://s3.dvulgsolucoes.com.br.s3.amazonaws.com/folder/filename.png

config.paperclip_defaults = {
  storage: :s3,
  s3_credentials: {
    bucket: 'bucketname.com.br',
    access_key_id: '###',
    secret_access_key: '###',
  }
}

Paperclip::Attachment.default_options[:url] = ':s3_domain_url'
Paperclip::Attachment.default_options[:path] = '/clients/dmg/:class/:attachment/:id_partition/:style/:filename'

【问题讨论】:

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


    【解决方案1】:

    您可以从回形针更改默认 URL 和路径,在初始化程序上编辑 paperclip.rb:

    Paperclip::Attachment.default_options[:url] = ':s3_domain_url'
    Paperclip::Attachment.default_options[:path] = '/:class/:attachment/:id_partition/:style/:filename'
    

    您可以从 Heroku 查看此链接

    https://devcenter.heroku.com/articles/paperclip-s3#configuration

    【讨论】:

      猜你喜欢
      • 2014-05-13
      • 1970-01-01
      • 2012-07-10
      • 1970-01-01
      • 1970-01-01
      • 2012-12-03
      • 1970-01-01
      • 1970-01-01
      • 2011-12-27
      相关资源
      最近更新 更多