Module: CarrierWave::Uploader::MagicMimeBlacklist

Extended by:
ActiveSupport::Concern
Defined in:
lib/carrierwave/uploader/magic_mime_blacklist.rb

Overview

This modules validates the content type of a file with the use of ruby-filemagic gem and a blacklist regular expression. If you want to use this, you’ll need to require this file:

require 'carrierwave/uploader/magic_mime_blacklist'

And then include it in your uploader:

class MyUploader < CarrierWave::Uploader::Base
  include CarrierWave::Uploader::MagicMimeBlacklist

  def blacklist_mime_type_pattern
    /image\//
  end
end

Instance Method Summary collapse

Instance Method Details

#blacklist_mime_type_patternObject

Override this method in your uploader to provide a black list pattern (regexp) of content-types which are prohibited to be uploaded. Compares the file’s content-type.

Returns

Regexp

a black list regexp to match the content_type

Examples

def blacklist_mime_type_pattern
  /(text|application)\/json/
end


50
# File 'lib/carrierwave/uploader/magic_mime_blacklist.rb', line 50

def blacklist_mime_type_pattern; end