A Rails engine to stream PostgreSQL Large Objects to clients
This gem adds to your application a controller that can read PostgreSQL Large Objects and stream them to a HTTP client.
For more information on PostgreSQL Large Objects you can take a look at the oficial docs
Add it to your Gemfile:
gem 'postgresql_lo_streamer'
Add to your config/routes.rb
the mount url where you are going to retrieve the files.
The following example will create a route /image_file/:id
where :id is the oid of the Large Object in the database:
mount PostgresqlLoStreamer::Engine => "/image_file"
If you are storing your files in the database using the carrierwave-postgresql gem, then your model will generate an URL like /<mode_name>_<attribute_name>/<oid>
.
So, for our previous example, if you have a model called Image
, with and attribute called file
(which is the oid referencing the Large Object), then the model will generate the URL matching our example. If you have more than one large object attribute in your database you can mount this engine multiple times with different URLs.
Copyright (c) 2012 Diogo Biazus. See MIT-LICENSE for further details.