Ruby on rails 如果“验证附件内容类型”失败,请避免创建样式

Ruby on rails 如果“验证附件内容类型”失败,请避免创建样式,ruby-on-rails,image-processing,amazon-s3,paperclip,Ruby On Rails,Image Processing,Amazon S3,Paperclip,我正在使用回形针gem管理Rails 3应用程序中的文件上传。我刚才补充说 validates_attachment_content_type :logo, :content_type => ['image/jpeg', 'image/png', 'image/gif'], :message => "should be \"PNG, GIF, or JPG\"" 对于我的模型来说,这似乎是可行的,除了我有4种样式需要在上传的图像上调用,而且即使验证失败,它们似乎也会被调用 以下是返

我正在使用回形针gem管理Rails 3应用程序中的文件上传。我刚才补充说

validates_attachment_content_type :logo, :content_type => ['image/jpeg', 'image/png', 'image/gif'], :message => "should be \"PNG, GIF, or JPG\""
对于我的模型来说,这似乎是可行的,除了我有4种样式需要在上传的图像上调用,而且即使验证失败,它们似乎也会被调用

以下是返回的验证错误

Logo content type should be "PNG, GIF, or JPG"    Logo /var/folders/cT/cTTe57AGGBiLXq0PUS+RBU+++TI/-Tmp-/stream20110509-3068-ti9gja.doc is not recognized by the 'identify' command.
Logo /var/folders/cT/cTTe57AGGBiLXq0PUS+RBU+++TI/-Tmp-/stream20110509-3068-ti9gja.doc is not recognized by the 'identify' command.
Logo /var/folders/cT/cTTe57AGGBiLXq0PUS+RBU+++TI/-Tmp-/stream20110509-3068-ti9gja.doc is not recognized by the 'identify' command.
Logo /var/folders/cT/cTTe57AGGBiLXq0PUS+RBU+++TI/-Tmp-/stream20110509-3068-ti9gja.doc is not recognized by the 'identify' command.
如何停止处理(或尝试这样做)样式


不确定这是否重要,但图像存储在Amazon s3中。

这似乎是回形针中的已知问题,没有人修复过。有一家商店,但已经关门了

另一种方法是在处理前后使用
验证类型。大致如下:

class Foobar
  before_post_process :check_content_type

  def check_content_type
    return ['image/jpeg', 'image/png', 'image/gif'].include?(logo.file_type)
  end
end

如果文件不适合这些内容类型,则应停止处理。

这似乎是回形针中的已知问题,没有人修复过。有一家商店,但已经关门了

另一种方法是在处理前后使用
验证类型。大致如下:

class Foobar
  before_post_process :check_content_type

  def check_content_type
    return ['image/jpeg', 'image/png', 'image/gif'].include?(logo.file_type)
  end
end
如果文件不适合这些内容类型,则应停止处理