Gem 用 Paperclip 的 paperclip:refresh:missing_styles 发现 S3 上会重复生成文件

fookwood · 2015年09月11日 · 1357 次阅读

我在做一个图片上传的功能,因为考虑到以后会使用不同 style 的图片。就想测试下增加 style 的时候需要如何操作。

我会先上传一张图片,然后去掉下面代码里的注释

class Post < ActiveRecord::Base
  belongs_to :user

  has_attached_file :image, {
    :path => "/images/:style/:hash.:extension",
    :hash_secret => "*DFNGKDFJKNGKDFKJLGD",
    :storage => :s3,
    :s3_credentials => "#{Rails.root}/config/aws.yml",
    #:styles => { thumb: "200x200#"}
  }
  validates_attachment_presence :image
  validates_attachment_file_name :image, matches: [/png\Z/, /jpe?g\Z/, /gif\Z/]
  validates_attachment_content_type :image, content_type: /\Aimage/

end

通过

rake paperclip:refresh:missing_styles

来生成 200*200 的图片。但是我发现上面的命令执行完了之后发现/images/original/下面会出现重复的图片,大小一样,内容一样,名字不一样 有人遇见过同样的问题么?

相关 Gem paperclip (4.3.0) rails (4.2.4) aws-sdk (1.66.0)

暂无回复。
需要 登录 后方可回复, 如果你还没有账号请 注册新账号