[Kimchi-devel] [PATCHv1 3/5] Storage volume upload: Parse params for upload formdata

Aline Manera alinefm at linux.vnet.ibm.com
Mon Sep 1 16:21:48 UTC 2014


Reviewed-by: Aline Manera <alinefm at linux.vnet.ibm.com>

On 09/01/2014 08:50 AM, lvroyce0210 at gmail.com wrote:
> 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)




More information about the Kimchi-devel mailing list