Download a file using Tornado

How to access uploaded file in Tornado when using put request?

 @require_basic_auth class UploadFile(tornado.web.RequestHandler): def put(self, params): path = calculate_path(params) # TODO: create an empty binary file at path and then copy # the request input stream to it. 
+7
source share
2 answers
 @require_basic_auth class UploadFile(tornado.web.RequestHandler): def put(self, params): path = calculate_path(params) with open(path, 'wb') as out: body = self.request.get_argument('data') out.write(bytes(body, 'utf8')) 

... this is what I need.

Found on some ActiveState pages.

+7
source

self.request.files should be fine. Here is an example.

+10
source

All Articles