Recently I came into a situation while deploying my app to heroku, I learned that heroku has an ephemeral storage, meaning that after every update to my api, all my uploads would be deleted.
So I investigated a little bit more of how I could keep my files and I finally got an answer: Use AWS S3 Storage.
Given that I had to use AWS and I didn't want to create an account (for laziness), I decided to just create one and instead of heroku and use and EC2 instance.
But now that I have configured my nginx, reverse proxy, ssl, etc, a question came to my mind. Should I use AWS S3 storage? Or Should I use the available space in the EC2 instance and just increase it when I need it?
My configuration is as follows: I have an API built using node.js and express, the app runs using pm2 and I configured a reverse proxy, so every time a user goes to a subdomain pointing to the ec2 instance, the reverse proxy listens in both port 80 and 443 and redirect the traffic to 127.0.0.1:5000
Now, the thing is that the user has to upload profile picture and some other files, and they are uploaded at the same level of my project.
-- Project Folder
-- routes
-- model
-- upload // I have subfolders here, and uploads are uploaded here.
-- index.js
So, should I leave my project as it is or should I change the way that my uploads work?
You can use S3 as storage for your uploaded files. But you would have to update your code to be able to use the S3 SDK for uploading files to S3 storage. There is nothing wrong in storing images in EC2 as well as long as you do not run into millions of them. So your current setup is fine.