We have a RoR 3.2 site on Heroku using their production tier PostgreSQL database.
Our site users occasionally upload images of 0.5 - 2MB in size. For different reasons we want to store those images in the database, rather than as files on S3 or similar.
If our site was image heavy, i.e. a Facebook clone, surely storing images in the db would not be a good thing.
Anyway, it is not, so here are some of the reasons for wanting to store a users images in the database:
- Control over everything: S3 downtime and third party gems cannot break image handling/access to images.
- Easy delete: If a user cancels his account, we can easily delete all associated images with that account through our rails models (relation dependencies).
- Easier user data export: When a user wants to leave our site and take his data with him, we can more easily export his images rather than having to export from S3
- Cost: Not a weighty argument, but since we're already paying for the database it will be cheaper than using S3 which costs (a small amount of) money.
- Backups: Not a weighty argument, but a backup of our db would include everything associated with our site (except the RoR code, of course).
What is the easiest way to store images in the Heroku PostgreSQL database? Example code or link to a walk-through would be most welcome.
Thanks :)