explaingit

carrierwaveuploader/carrierwave

8,776RubyAudience · developerComplexity · 2/5Setup · easy

TLDR

Ruby library for handling file uploads in web applications, letting you attach user-uploaded photos or documents to database records and store them on local disk or cloud storage with minimal code.

Mindmap

mindmap
  root((CarrierWave))
    What it does
      Handles file uploads
      Stores files
      Image transformations
    Storage options
      Local disk
      Amazon S3
      Other cloud services
    Features
      Single file upload
      Multiple file upload
      File versioning
      Type validation
    Rails integration
      Uploader class
      Model mounting
      Generator scaffold
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Add profile photo uploads to a Rails app and automatically resize images into multiple thumbnail sizes

USE CASE 2

Accept document uploads from users and store them in Amazon S3 via CarrierWave's S3 integration

USE CASE 3

Support multi-file uploads like a photo gallery stored as a JSON array in a single database column

Tech stack

RubyRuby on RailsRack

Getting it running

Difficulty · easy Time to first run · 30min

Requires an existing Ruby on Rails or Rack app, cloud storage options need additional gem configuration.

In plain English

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.

Copy-paste prompts

Prompt 1
Show me how to add CarrierWave to a Rails app to let users upload a profile photo and automatically generate a thumbnail version
Prompt 2
How do I configure CarrierWave to store uploaded files in Amazon S3 instead of local disk, what gems and config do I need?
Prompt 3
Write the CarrierWave uploader class and Rails model setup needed to accept PDF uploads with file extension validation
Open on GitHub → Explain another repo

← carrierwaveuploader on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.