Commits

sempr committed 8518648

MOD: add base64 upload method

Comments (0)

Files changed (1)

     @tornado.web.asynchronous
     @tornado.gen.engine
     def post(self,channel):
-        file = self.request.files['file'][0]
+        p_type = self.get_argument('type','nor')
+        if p_type == 'b64':
+            binary = base64.b64decode(self.get_argument('data'))
+            filename = self.get_argument('filename')
+            file = {'body':binary,'filename':filename,'content_type':'application/file'}
+        else:
+            file = self.request.files['file'][0]
+        print file
         # save file first
         file_path = os.path.join(os.path.dirname(__file__),"static","upload",str(int(time.time())))
         os.makedirs(file_path)