problem in file format validation with gem paperclip 5.1.0, rails 5

1

Model

has_attached_file :foto
validates_attachment_content_type :foto, content_type: /\Aimage\/.*\z/

Error in log

Command :: file -b --mime "C:/Users/conta/AppData/Local/Temp/66c9eed121277d8be2df09ce25c4687a20171106-5872-1j1pihz.jpg"
[paperclip] Content Type Spoof: Filename foto.jpg (image/jpeg from Headers, ["image/jpeg"] from Extension),content type discovered from file command: . See documentation to allow this combination.

    
asked by anonymous 06.11.2017 / 05:45

1 answer

0

If you want to disable spoofing protection, create the file:

config / initializers / paperclip_media_type_spoof_detector_override.rb

And add the code to it:

require 'paperclip/media_type_spoof_detector'
module Paperclip
  class MediaTypeSpoofDetector
    def spoofed?
      false
    end
  end
end
    
14.11.2017 / 00:37