module Bizside::Uploader::ContentTypeValidator
Public Instance Methods
content_type_checklist()
click to toggle source
# File lib/bizside/uploader/content_type_validator.rb, line 19 def content_type_checklist %w(jpg jpeg gif png) end
Private Instance Methods
validate_content_type!(new_file)
click to toggle source
# File lib/bizside/uploader/content_type_validator.rb, line 25 def validate_content_type!(new_file) return if new_file.path.nil? extension = new_file.extension.to_s if content_type_checklist.include?(extension.downcase) by_path = MimeMagic.by_extension(extension).to_s unless new_file.content_type == by_path raise CarrierWave::IntegrityError, I18n.translate(:"errors.messages.content_type_whitelist_error", content_type: new_file.content_type) end end end