Module: CarrierWave::Uploader::MagicMimeWhitelist

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

Overview

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

require 'carrierwave/uploader/magic_mime_whitelist'

And then include it in your uploader:

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

  def whitelist_mime_type_pattern
    /image\//
  end
end

Instance Method Summary collapse

Instance Method Details

#whitelist_mime_type_patternObject

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

Returns

Regexp

a white list regexp to match the content_type

Examples

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


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

def whitelist_mime_type_pattern; end