Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Store image in database using rails paperclip plugin

I have an application that uses the Paperclip plugin for image upload. Now that app should get deployed to an host(heroku) which has a read-only file system. Can I somehow tell paperclip to store the images in the database?

like image 840
mc. Avatar asked Oct 20 '09 19:10

mc.


3 Answers

Heroku recommends storing file uploads on s3, and provides instructions on how to do so for several Rails file plugins.

like image 34
ry. Avatar answered Sep 27 '22 21:09

ry.


Rethink what you're doing. Storing images in the db is generally a bad idea. For more info, see here.

ry is right to point you towards S3. If nothing else, think of the cost: 500 MB of database space on Heroku is $50/month. On S3, it'll be 15 cents.

like image 21
PreciousBodilyFluids Avatar answered Sep 27 '22 23:09

PreciousBodilyFluids


Check out this sample app

http://patshaughnessy.net/2009/5/29/paperclip-sample-app-part-3-saving-file-attachments-in-a-database-blob-column

I guess this is exactly what you need.

HTH

PS: storing images in db is usually a bad idea, I am sure you can use paperclip with S3 / cloudfront ( as mentioned in the answers below )

like image 176
Rishav Rastogi Avatar answered Sep 27 '22 21:09

Rishav Rastogi