Rails 5,回形针没有验证附件?

时间:2017-10-21 16:02:35

标签: ruby-on-rails paperclip

我收到了这个回复:

Command :: file -b --mime "C:/Users/Ben/AppData/Local/Temp/5523c88dd347d1b7cc617f632b7efdb720171021-12076-b6btes.jpg"
[paperclip] Content Type Spoof: Filename bg.jpg (image/jpeg from Headers, ["image/jpeg"] from Extension), content type discovered from file command: . See documentation to allow this combination.
   (0.0ms)  BEGIN
Command :: file -b --mime "C:/Users/Ben/AppData/Local/Temp/5523c88dd347d1b7cc617f632b7efdb720171021-12076-1fvpv4a.jpg"
[paperclip] Content Type Spoof: Filename bg.jpg (image/jpeg from Headers, ["image/jpeg"] from Extension), content type discovered from file command: . See documentation to allow this combination.
   (0.6ms)  ROLLBACK

在Windows上

我的模型中有这个:

  has_attached_file :image
  # Validate content type
  validates_attachment_content_type :image, content_type: /\Aimage\/.*\Z/
  # Explicitly do not validate
  do_not_validate_attachment_file_type :image

请求失败了,我不明白为什么会这样?

1 个答案:

答案 0 :(得分:0)

尝试:

配置/初始化/ paperclip.rb:

size()