Flask-WTF FileField Uploaded file disappears after a couple days and doesn't show up in the folder

StackOverflow https://stackoverflow.com/questions/23232609

  •  07-07-2023
  •  | 
  •  

Question

So I'm just using the FileField to add files to the server and it worked the time I tested it on Heroku (by worked I mean the image was rendering properly, granted I should be using some more proper ways to render images), but after a couple days I checked again and the image is no longer rendering properly. I checked my uploads folder and the image is not there any longer (one of the old images were).

I ran the test again and the image is showing but the picture file is not in the uploads folder (despite the image showing). I checked on my local machine with the same code and the image uploaded showed up in the uploads folder.

I have no clue what's going on... It would be great if someone could shed some insights!

Thanks!

Was it helpful?

Solution

The "problem" (it is in fact by design) is with Heroku. Every time your application restarts (when a new change is pushed to your Heroku application or when it restarts after inactivity) your app is recreated and all stored data is gone. Most people use an external service for persistent files/data such as Amazon S3.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top