rails paperclip不同的文件类型问题

时间:2009-10-08 18:27:10

标签: ruby-on-rails paperclip

我正在使用回形针上传文件,处理图像很简单,但是当我必须创建不同风格的图像时,如何处理同一上传中的图像(png,jpg)和swf,甚至是pdf文件不是其他格式。

3 个答案:

答案 0 :(得分:3)

虽然接受的答案已经过时,但解决方案似乎是:

  before_post_process :is_image?
  def is_image?
    !(asset_content_type =~ /^image/).nil?
  end

假设您的附件名为asset。根据需要进行修改。

答案 1 :(得分:0)

答案 2 :(得分:0)

工作代码是

before_post_process :is_image?
def is_image?
  !(self.pc.content_type =~ /^image/).nil?
end

“pc”是您的附件名称