Classier solution for file uploads for Rails, Sinatra and other Ruby web frameworks
open sourceMITfree
CarrierWave is a Ruby gem for handling file uploads in Rack-based apps such as Ruby on Rails and Sinatra. You generate an uploader class, mount it on an ActiveRecord model column, and the uploader decides where files are stored, how they're named, which types are allowed and which processed versions, such as thumbnails, to create with MiniMagick, RMagick or Vips. Files can live on the local filesystem or, through Fog, on Amazon S3, Google Cloud Storage or Rackspace, and uploads survive form redisplays and can be fetched from remote URLs. Separate gems add Mongoid, Sequel and DataMapper support. It is MIT licensed and has been maintained since 2008.
Problems it solves
- handle file and image uploads in my Rails app
- generate thumbnails of uploaded images in Ruby
- store Rails uploads on Amazon S3 or Google Cloud Storage
- keep an uploaded file when a form fails validation and is shown again
- migrate a Rails app off Paperclip
Features
- uploader classes mounted on ActiveRecord models, with single and multiple file uploads
- processed versions, including conditional and nested versions, with MiniMagick, RMagick or Vips
- local file storage or cloud storage through Fog: Amazon S3, Google Cloud Storage and Rackspace
- extension and content type allowlists and denylists for securing uploads
- uploads kept across form redisplays and downloads from remote URLs with retries
- default URLs, recreating versions, I18n and test helpers
- Mongoid, Sequel and DataMapper support in separate gems
- migration guide from Paperclip
Limitations
- Only the latest release line gets fixes; CarrierWave 3.1 supports Rails 6.0 to 8.0 and Ruby 2.5 or later, and 4.0 (in release candidate) Rails 7.0 to 8.11
Alternatives
The same job
These do what CarrierWave does.