I receive files by @tornado.web.stream_request_body decorator and save it. But with one file if I try to download it, i receive exception:
'latin-1' codec can't encode characters in position 42-47: ordinal not in range(256)
in line
self.flush()
of tornado handler.
I see that data contain part as a \x00word/_rels/document.xml.relsPK\x01\x02-\
(b"some data [this part]")
Maybe that's why an error occurs? How to fix it?
I fix problem. urlencode name of file in Content-Disposition header:
self.set_header('Content-Disposition',
'attachment; filename=' + urllib.parse.quote(file_name, safe=""))