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

笑着哭i 提交于 2021-02-11 16:49:21

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!