I want the ability to allow users to upload their avatar. While it works, I also noticed it will disappear after some time due to the file system by heroku:
The Heroku filesystem is ephemeral - that means that any changes to the filesystem whilst the dyno is running only last until that dyno is shut down or restarted. Each dyno boots with a clean copy of the filesystem from the most recent deploy. This is similar to how many container based systems, such as Docker, operate.
It recommends me to use AWS S3 storage but I know it's not free. Are there any alternatives that I can get by?
@nickywan123 Heroku’s filesystem is temporary. Anything uploaded will be forgotten as your app is served by “dynos” and not a single web server. So an image uploaded to one dyno will be lost when Heroku switches to another dyno to serve your app.
You’ll need to use something like S3 to persist files. There’s no way around it.
@nickywan123 Why do you think someone is going to let you upload and store files for free…?
S3 has a free tier. But you’ve given no indication as to what you’re wanting to store, so it may be free, it may be pennies, it may be thousands of dollars.
Right. So you’ve got to store them somewhere? If you used a shared host, you’d be paying them for disk space. If you had a VPS, you’d pay for disk space on that. If you use S3, you pay for what you store there.