Tornado: mime-type of the stream_request_body output

后端 未结 2 1814
情歌与酒
情歌与酒 2021-02-10 18:53

I\'m using tornado.web.stream_request_body (tornado v4.0.1) to save post data but it seems like mime-type of the saved files remain as application/octet-strea

2条回答
  •  星月不相逢
    2021-02-10 19:42

    In stream_request_body mode you get the raw body as uploaded by the client, without the processing that creates self.request.arguments or self.request.files. This is a multipart/form-data wrapper (not the http headers, although they do look similar); you'll need to parse this to get the filename and the embedded data. I think the mime-related tools in the standard library's email package are probably the best way to parse this once you've gotten it saved to a file.

提交回复
热议问题