Search code examples
javascriptdjangoheroku

How to upload an image temporarily on Heroku?


I am facing the following issue: I have deployed a Django-app to the Heroku and want to upload an image using file input. But it should not be storing there, it could be deleted after I reload the page, but I want to have URL to this image for that time. So, I have no idea how to do this at all, can someone help me?


Solution

  • 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.

    In addition, under normal operations dynos will restart every day in a process known as "Cycling".

    for more information read this documentation https://help.heroku.com/K1PPS2WM/why-are-my-file-uploads-missing-deleted

    what i would instead of using aws s3 bucket use cloudinary which is fast free to use upto 25gb how to use it read this full documetation https://www.section.io/engineering-education/uploading-images-to-cloudinary-from-django-application/ and for static file use whitenoise which i am also using and recommending i hope this will help you to solve your problem