carrierwave

https://github.com/jnicklas/carrierwave

Ruby

Classier solution for file uploads for Rails, Sinatra and other Ruby web frameworks

CarrierWave::Uploader::ContentTypeWhitelist#content_type_whitelist

Override this method in your uploader to provide a whitelist of files content types
which are allowed to be uploaded.
Not only strings but Regexp are allowed as well.

=== Returns

[NilClass, String, Regexp, Array[String, Regexp]] a whitelist of content types which are allowed to be uploaded

=== Examples

    def content_type_whitelist
      %w(text/json application/json)
    end

Basically the same, but using a Regexp:

    def content_type_whitelist
      [/(text|application)\/json/]
    end

Source | Google | Stack overflow

Edit

git clone [email protected]:jnicklas/carrierwave.git

cd carrierwave

open lib/carrierwave/uploader/content_type_whitelist.rb

Contribute

# Make a new branch

git checkout -b -your-name--update-docs-CarrierWave--Uploader--ContentTypeWhitelist-content_type_whitelist-for-pr


# Commit to git

git add lib/carrierwave/uploader/content_type_whitelist.rbgit commit -m "better docs for CarrierWave::Uploader::ContentTypeWhitelist#content_type_whitelist"


# Open pull request

gem install hub # on a mac you can `brew install hub`

hub fork

git push <your name> -your-name--update-docs-CarrierWave--Uploader--ContentTypeWhitelist-content_type_whitelist-for-pr

hub pull-request


# Celebrate!