Search code examples
javascriptnode.jsherokubackendmulter

how to make files that have been uploaded to the backend with the Heroku server not orderly when deploying again


I have a backend application using node js, the application can accept files uploaded to the server by multer then the path is stored in the mongodb database. I push this application to gitlab by continuously deployment it to the heroku server. When I try to upload the image to the server there is no problem and the image can appear on the static route (public), but when I update the code and push it to gitlab again, the image that was previously uploaded is now not showing. What should I do


Solution

  • Heroku's filesystem is ephemeral/short lived. Meaning, any images you upload will disappear after you redeploy your app. You can't rely on Heroku's filesystem to store images that need to persist for a longer time.

    For saving images, have a look at 3rd party storage solutions such as Cloudinary or AWS S3.