File Attachment toolkit for Ruby applications
open sourceMITself-hostablefree
Shrine is a toolkit for handling file uploads and attachments in Ruby applications, built from plugins so an app loads only what it needs. It streams uploads and downloads for large files, stores files on disk, S3, Google Cloud Storage, Cloudinary and others, and integrates with Active Record, Sequel, ROM, Hanami and Mongoid. It supports direct and resumable uploads with Uppy (S3 presigned, S3 multipart, tus), eager or on-the-fly processing with ImageMagick or libvips, metadata extraction and validation, and background processing with any job library. Unlike Active Storage it does not depend on Rails.
Problems it solves
- let users upload files straight to S3 from the browser without going through my Ruby server
- handle file attachments in a Sinatra, Roda or Hanami app that doesn't use Rails
- large video uploads keep failing halfway and need to be resumable
- generate image thumbnails on the fly instead of up front
- move image processing for uploads into background jobs
- Active Storage doesn't fit how we want to store attachment metadata on our own table
- validate uploaded files by real MIME type, size and image dimensions
- file uploads load the whole file into memory and the server runs out of RAM
- keep an uploaded file when the form fails validation and is shown again
- attach files to Sequel or ROM models
- replace a deprecated Paperclip setup in an old Rails app
Features
- plugin system
- streaming uploads and downloads
- storages: file system, S3, Google Cloud Storage, Cloudinary and more
- ORM plugins: Active Record, Sequel, ROM, Hanami, Mongoid
- eager and on-the-fly processing (derivatives)
- ImageMagick or libvips via image_processing
- metadata extraction and validation
- direct uploads to the app or to cloud storage with Uppy
- resumable uploads (S3 multipart, tus)
- background processing with any job library
Capabilities
| Takes plugins | plan not known |
|---|
Alternatives
The same job
These do what Shrine does.
- CarrierWave Classier solution for file uploads for Rails, Sinatra and other Ruby web frameworks
- Paperclip The app people use to manage AI agents for work
- Dragonfly The world's most efficient in-memory data store