No commit activity in last 3 years
No release in over 3 years
This gem is a quick way to add database-backed file storage to a Rails application. Files are stored in a dedicated table and de-duplicated.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 1.6.6
>= 2.1.1
>= 1.2.1
>= 0.4.4
>= 1.3.1
>= 0.19.0
>= 11.3.0
>= 0
>= 1.3.12
>= 0.9.5

Runtime

>= 5.0.0.1
 Project Readme

file_blobs_rails

This is a Ruby on Rails engine that contains the infrastructure for storing files in the application's database.

The file metadata is inlined in the model that contains the file, so details like the file's size and type can be displayed in views quickly. The file contents is stored in a dedicated blobs table, so it is only loaded in the application's memory when the file is explicitly requested.

The engine implements content deduplication and etag-based caching.

Integration

Create the model that will host the file contents. The idiomatic name for this model is FileBlob.

rails g file_blobs:blob_model file_blob

Scaffold a model that will contain a file. The default attribute name is file.

rails g file_blobs:blob_owner message --attr_name attachment

An easy way to add file storage functionality to an existing model is to scaffold a new model, move the generated code into your existing model, and remove the scaffold.

Use send_file_blob to serve a file from a controller action. The method takes the same options as the Rails built in send_data method

send_file_blob @blob_owner.file, disposition: :inline

Contributing to file_blobs_rails

  • Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
  • Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
  • Fork the project.
  • Start a feature/bugfix branch.
  • Commit and push until you are happy with your contribution.
  • Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
  • Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.

Copyright

Copyright (c) 2016 Victor Costan, released under the MIT license.