在Flask(Flask-0.10.1通过pip安装)中,我尝试处理像这样上传的文件
f = flask.request.files[input_name]
stream = f.stream
# then use the stream
但令人困惑的是,在某些情况下,stream
是一个BytesIO
实例,但同时也是一个file
对象的机会。在
我用这种方法测试过
^{pr2}$它印出来了
<type '_io.BytesIO'>
<type 'file'>
PNG文件来自github:
http://octodex.github.com/images/homercat.pnghttp://octodex.github.com/images/megacat-2.png
我想知道烧瓶为什么会这样。如果我希望上传的数据进入数据库,在这两种情况下都可以调用f.stream.read()
?在
小于1024*500字节的文件将写入StringIO对象,而大于该阈值的文件将写入临时文件。在
它是Werkzeug测试框架的一部分,但该功能不是在线文档的一部分:
Source
相关问题 更多 >
编程相关推荐