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.
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.
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.
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.
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.
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?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With