LazyBlobStorage
Useful for attaching small (size < 3 MB) database-backed blobs to records. Good when you need small file upload support, but don't want to bother with a cloud service because you know you'll have low traffic/user counts. Uses a SHA256 digest to prevent duplicate blob uploads.
Doesn't do anything fancy. Just stores files and allows public access using the digest as a key. Respects HTTP Cache headers.
Note
If it's not obvious. This is for inclusion in a Rails app.
Build with Rails 6. It'll ~probably~ work with Rails 4/5, too.
Usage
- Add
gem "lazy_blob_storage" to Gemfile
- Run
rake db:migrate
- Declare
has_lazy_attached :image
in some model - Add
f.file_field :image_upload
to the form template - Use
image_tag @thing.attached_image_path
orimage_tag @thing.image_url
Note: LazyBlobsController respects HTTP cache directives
License
The gem is available as open source under the terms of the MIT License.