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

  1. Add gem "lazy_blob_storage" to Gemfile
  2. Run rake db:migrate
  3. Declare has_lazy_attached :image in some model
  4. Add f.file_field :image_upload to the form template
  5. Use image_tag @thing.attached_image_path or image_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.