问题
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!
回答1:
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.
来源:https://stackoverflow.com/questions/23232609/flask-wtf-filefield-uploaded-file-disappears-after-a-couple-days-and-doesnt-sho