简体   繁体   English

如何在Flask中获取文件上传状态

[英]How to get status of uploading file in Flask

There is a need to add some kind of an upload progress dialog to my application. 有必要在我的应用程序中添加某种上传进度对话框。 I know there are plenty of Flash/Java/HTML5 solutions for that, however they are not suitable in my case. 我知道有很多Flash / Java / HTML5解决方案,但是它们不适用于我的情况。

Flask documentation gives "an easier solution" offering Flask-Uploads extension. Flask 文档提供了Flask-Uploads扩展的“更简单的解决方案”。 However I haven't found any kind of solution for my question there. 但是我在那里没有找到任何解决方案。

Is there any possibility to get the status of uploading file (ie number of bytes already uploaded)? 是否有可能获得上传文件的状态(即已上传的字节数)?

In fact, I know that Flask accumulates the file data in memory if file size is not big. 实际上,我知道如果文件大小不大,Flask会在内存中累积文件数据。 Otherwise, it stores the file in the temporary folder. 否则,它将文件存储在临时文件夹中。 If there are no options of getting the number of received bytes, maybe there are ways of getting the temp filename at least? 如果没有获取接收字节数的选项,也许至少有一些获取临时文件名的方法?

Any kind of tricks are very welcome. 任何花样都非常欢迎。

Thanks for help! 感谢帮助!

I don't think it is related to Flask 我不认为这与Flask有关

Please see this link: 请查看此链接:

I think these are be helpful 我认为这些会有所帮助

request.META['REMOTE_ADDR'], request.GET['X-Progress-ID']

我尚未对其进行测试,但在此处找到了类似内容的链接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM