Add profile photo uploads to a Rails app and automatically resize images into multiple thumbnail sizes
Accept document uploads from users and store them in Amazon S3 via CarrierWave's S3 integration
Support multi-file uploads like a photo gallery stored as a JSON array in a single database column
Requires an existing Ruby on Rails or Rack app, cloud storage options need additional gem configuration.
CarrierWave is a Ruby library that handles file uploads in web applications. It works with Ruby on Rails and other web frameworks built on top of Rack, the common Ruby web server interface. Developers add it to their project to manage how user-uploaded files, like profile photos or documents, are received, stored, and served back. The library centers on a concept called an uploader, which is a class you define to describe the rules for a particular type of file. A generator command scaffolds the class for you, and from there you decide where files go (local disk or a cloud storage service), what transformations to apply (like resizing an image), and how filenames are handled. Once the uploader class is set up, you attach it to a database column in your model with a single line, and the library wires everything together so that assigning a file to the model attribute automatically handles saving and retrieving it. Both single-file and multiple-file uploads are supported. For multiple files, you mount the uploader with a slightly different method name and store the list in a JSON or array column in the database. Files can be stored on the local filesystem or on external services. Other options, such as Amazon S3, are available through additional configuration. You can also create multiple versions of an uploaded file, which is useful for generating thumbnails at different sizes from an original image. The README covers upgrading between versions, validating file types and sizes, white-listing allowed extensions, and integration with image-processing libraries. The full README is longer than what was shown.
← carrierwaveuploader on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.