New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

lazy_blob_storage

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lazy_blob_storage

  • 2.0.0.pre.beta.9
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

LazyBlobStorage

Useful for attaching small 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.

Nothing fancy. Just stores files and allows public access using the digest as a key. Respects HTTP Cache headers.

You probably want to put a CDN/Cache/RateLimit in front of the "lazy_blobs#show" route because somebody could DOS your website if all your workers are serving files from the database.

Basically this is a dumb idea, but setting up AWS buckets and permissions just to upload a dumb logo is :big_sigh_emoji:

Don't use this. I mean it.

Alternative

I would use activestorage_database rather than lazy_blob_storage if I were starting a new project.

See:

  • https://rubygems.org/gems/activestorage_database
  • https://github.com/WizardComputer/activestorage_database

Breaking Changes in 2.0.0-beta.1

  • Support UUID key types
  • YOLO support for rails > 6 (it's probably fine)
  • Migrations do not get added to rails paths automatically anymore. They must be copied with the lazy_blob_storage:install:migrations rake task.
  • The default max blob size is 100kb. It should probably be lower. You can set this to a number of bytes with LazyBlobStorage.max_blob_size=
  • !!! Do not use this for high traffic projects. !!!
  • !!! Do not use this to store big files !!!
  • !!! This dumb idea only works for very small files like 10kb logos or icons. !!!
  • !!! you were warned !!!

Note

If it's not obvious. This is for inclusion in a Rails app.

Built with Rails 6. It could probably work with Rails 4/5, too.

Usage

  1. Add gem "lazy_blob_storage" to Gemfile
  2. Run rake lazy_blob_storage_engine:install:migrations
  3. Run rake db:migrate
  4. Declare has_lazy_attached :image in some model
  5. Add f.file_field :image_upload to the form template
  6. Use image_tag @thing.lazy_attached_image_path or image_tag @thing.lazy_image_url

Note: LazyBlobsController respects HTTP cache directives

License

The gem is available as open source under the terms of the MIT License.

FAQs

Package last updated on 24 Aug 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc