Flask: Get gzip filename sent from Postman

前端 未结 1 533
我寻月下人不归
我寻月下人不归 2020-12-12 06:10

I am sending a gzip file from Postman to a Flask endpoint. I can take that binary file with request.data and read it, save it, upload it, etc.

My proble

相关标签:
1条回答
  • 2020-12-12 06:43

    Further to the comment, I think the code which handles your upload is relevant here.

    See this answer regarding request.data:

    request.data Contains the incoming request data as string in case it came with a mimetype Flask does not handle.

    The recommended way to handle file uploads in flask is to use:

    file = request.files['file']
    
    • file is then of type: werkzeug.datastructures.FileStorage.

    • file.stream is the stream, which can be read with file.stream.read() or simply file.read()

    • file.filename is the filename as specified on the client.

    • file.save(path) a method which saves the file to disk. path should be a string like '/some/location/file.ext'

    source

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