加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – 如何为亚马逊s3图像添加过期标题?

发布时间:2020-12-16 23:33:08 所属栏目:百科 来源:网络整理
导读:在我的模型中,它使用的是回形针.我添加了 this行代码,但仍无效 has_attached_file :attachment,{ :styles = { :medium = ["654x5000000",:jpg],:small = ["260x50000000",:thumb = ["75x75#",:facebook_meta_tag =["200x200#",:jpg] },:convert_options = {
在我的模型中,它使用的是回形针.我添加了 this行代码,但仍无效
has_attached_file :attachment,{
    :styles => {
      :medium => ["654x5000000>",:jpg],:small => ["260x50000000>",:thumb => ["75x75#",:facebook_meta_tag =>["200x200#",:jpg] 
    },:convert_options => {
       :medium => "-quality 80 -interlace Plane",:small => "-quality 80 -interlace Plane",:thumb => "-quality 80 -interlace Plane",:facebook_meta_tag => "-quality 80 -interlace Plane" 
       },:s3_headers => { 'Cache-Control' => 'max-age=315576000','Expires' => 10.years.from_now.httpdate } 
    }.merge(PAPERCLIP_STORAGE_OPTIONS)

PS:我在GTmetrix.com进行了测试,根据他们的统计数据,亚马逊图像中没有到期标题.

解决方法

为了扩展James对其他人不确定如何重新处理旧附件的回答,有两种方法可以做到:

1)通过rake重新处理所有附件(可选择每个CLASS)

rake paperclip:refresh CLASS=User

2)重新处理特定附件(例如通过迁移)

User.where("attachment IS NOT NULL").find_each do |user|
  user.attachment.reprocess!
end

有关详细信息,请参阅https://github.com/thoughtbot/paperclip/wiki/Thumbnail-Generation#generatingregenerating-your-thumbnails

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读