Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is a good way to store binary files on Heroku?

Tags:

node.js

heroku

I am using Node.js on Heroku, and use MongoHQ for data.

My app needs to be able to store image files, that are uploaded from the user or pulled down from other sites. I'm not looking for add-on to do image processing or the like, I just need to be able to store them and serve them. It is fine if I just reference them from within my Node app as a numerical id or the like.

Being as this is a one-person, self-funded project, I'd like to do this as cheaply as possible (I don't want to pay a lot of fees for add-ons) and prefer keep everything on Heroku for simplicity (although the latter is not a requirement, just a preference). I know I could store them in Mongo as binary, but I'm looking for something more efficient and hopefully cheaper per meg of storage.

like image 336
rob Avatar asked May 19 '12 20:05

rob


People also ask

Can you store files in Heroku?

Heroku has an “ephemeral” hard drive, this means that you can write files to disk, but those files will not persist after the application is restarted. By default Active Storage uses a :local storage option, which uses the local file system to store any uploaded files.

Does Heroku have persistent storage?

Heroku does not provide any sort of persistent storage on dynos. If you need to persist files across sessions, you must use object storage such as Amazon S3.

How are binary files stored?

Serialisation is the process of converting an object (such as a dictionary of data) into binary sequences that can be stored in a file. When the file is accessed, the binary data is retrieved from the file and deserialised into objects that are exact copies of the original information.

Is Heroku free forever?

Free Services on Heroku Heroku offers a free plan to help you learn and get started on the platform. Heroku Buttons and Buildpacks are free, and many Heroku Add-ons also offer a free plan.


1 Answers

Amazon S3 is the suggested way to do this - I use it all the time with heroku:

https://devcenter.heroku.com/articles/s3

Here are some node.js specific resources:

http://toolbox.no.de/search?q=s3

Node.js & Amazon S3: How to iterate through all files in a bucket?

like image 153
Andrew Kuklewicz Avatar answered Oct 01 '22 02:10

Andrew Kuklewicz