[Kimchi-devel] [PATCH v5 3/7] Storage volume upload: Parse params for upload formdata

Crístian Viana vianac at linux.vnet.ibm.com
Fri Sep 5 16:44:52 UTC 2014


From: Royce Lv <lvroyce at linux.vnet.ibm.com>

When pass form to cherrypy, it is stored in cherrypy.request.params,
so adjust parse_request for this change.
Also avoid body parse so that file content will not be loaded into mem.

Signed-off-by: Royce Lv <lvroyce at linux.vnet.ibm.com>
---
 src/kimchi/control/utils.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/kimchi/control/utils.py b/src/kimchi/control/utils.py
index fbd5177..64e0ac5 100644
--- a/src/kimchi/control/utils.py
+++ b/src/kimchi/control/utils.py
@@ -72,14 +72,16 @@ def mime_in_header(header, mime):
 def parse_request():
     if 'Content-Length' not in cherrypy.request.headers:
         return {}
-    rawbody = cherrypy.request.body.read()
 
     if mime_in_header('Content-Type', 'application/json'):
+        rawbody = cherrypy.request.body.read()
         try:
             return json.loads(rawbody)
         except ValueError:
             e = OperationFailed('KCHAPI0006E')
             raise cherrypy.HTTPError(400, e.message)
+    elif mime_in_header('Content-Type', 'multipart/form-data'):
+        return cherrypy.request.params
     else:
         e = OperationFailed('KCHAPI0007E')
         raise cherrypy.HTTPError(415, e.message)
-- 
1.9.3




More information about the Kimchi-devel mailing list