Shrine is a file attachment toolkit for Ruby applications that handles uploads, storage, and processing through a modular plugin system.
Shrine solves the problem of managing file attachments across different storage backends and ORM frameworks by providing a unified interface. It uses a modular architecture where you load only the plugins you need, keeping the core lightweight. The toolkit supports streaming for memory-efficient handling of large files, integrates with multiple storage options including disk, AWS S3, Google Cloud, and Cloudinary, and works with persistence layers like ActiveRecord, Sequel, ROM, Hanami, and Mongoid. It enables flexible file processing through eager or on-the-fly thumbnail generation using ImageMagick or libvips, validates files based on extracted metadata, and supports both simple and presigned direct uploads to reduce server load.
Shrine suits applications that need reliable file handling without being locked into a specific storage backend or ORM. It works well for projects requiring large file uploads, background processing of attachments, or resumable uploads on S3 or tus servers. The README names Paperclip, CarrierWave, Dragonfly, Refile, and Active Storage as similar libraries but does not detail how Shrine compares to them beyond noting that it was inspired by Refile's backend concept and direct upload approach, and by Roda's plugin system design.
The project maintains active discussion forums and a wiki alongside its main documentation site. Contributions are guided by a code of conduct and documented contributing guidelines. The toolkit has demo implementations available for both Roda and Rails frameworks to help developers understand integration patterns.