I'm trying to use @tornado.web.stream_request_body for upload files.
But I have a problem with upload large files. For example, when I upload PDF file larger than 100 MB (https://yadi.sk/i/rzLQ96pk3Tcef6) it loads incorrectly and it doesn't open in viewers.
Code example:
MAX_STREAMED_SIZE = 1024 * 1024 * 1024
@tornado.web.stream_request_body
class UploadHandler(tornado.web.RequestHandler):
def prepare(self):
self.request.connection.set_max_body_size(MAX_STREAMED_SIZE)
self.f = open(os.path.join('files', '12322.pdf'), "w+b")
def data_received(self, data):
self.f.write(data)
def post(self):
self.f.close()
print("upload completed")
What can be the reason of the problem?
Try this. Work fine with one file upload, no large mem usage
This is my solution == >
Python code:
Html code :