Python - What type is flask.request.files.stream supposed to be?

前端 未结 1 1155
失恋的感觉
失恋的感觉 2021-01-13 18:24

In Flask (Flask-0.10.1 installed via pip) I\'ve tried to handle uploaded files like this

f = flask.request.files[input_name]
stream = f.stream
# then use the         


        
相关标签:
1条回答
  • 2021-01-13 18:57

    Files smaller than 1024 * 500 bytes are written to a StringIO object, while files greater than that threshold are written to temporary files.

    It's part of Werkzeug's testing framework, but that function isn't part of the online documentation:

    def stream_encode_multipart(values, use_tempfile=True, threshold=1024 * 500,
                                boundary=None, charset='utf-8'):
        """Encode a dict of values (either strings or file descriptors or
        :class:`FileStorage` objects.) into a multipart encoded string stored
        in a file descriptor.
        """
    
        ...
    

    Source

    0 讨论(0)
提交回复
热议问题