Flask-WTF FileField上载的文件会在几天后消失,并且不会显示在文件夹中 [英] Flask-WTF FileField Uploaded file disappears after a couple days and doesn't show up in the folder

查看:55
本文介绍了Flask-WTF FileField上载的文件会在几天后消失,并且不会显示在文件夹中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我只是使用FileField将文件添加到服务器,并且它在我在Heroku上进行测试时就起作用了(通过工作,我是指图像可以正确渲染,当然我应该使用一些更正确的方法来渲染图像)),但过了几天我又检查了一下,图像不再能正常渲染.我检查了我的上载文件夹,图像不再存在(其中一张是旧图像).

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

我再次运行测试,虽然显示了图像,但是图片文件不在上载文件夹中(尽管显示了图像).我使用相同的代码在本地计算机上进行了检查,并且上传的图像显示在uploads文件夹中.

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!

谢谢!

推荐答案

问题"(实际上是设计使然)与Heroku有关.每次您的应用程序重新启动时(将新的更改推送到您的Heroku应用程序时,或者在不活动后重新启动时),都会重新创建您的应用程序,并且所有存储的数据都将消失.大多数人使用外部服务来存储持久性文件/数据,例如Amazon S3.

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.

这篇关于Flask-WTF FileField上载的文件会在几天后消失,并且不会显示在文件夹中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆