summaryrefslogtreecommitdiffstats
path: root/module
diff options
context:
space:
mode:
Diffstat (limited to 'module')
-rw-r--r--module/obmc/wsgi/apps/rest_dbus.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/module/obmc/wsgi/apps/rest_dbus.py b/module/obmc/wsgi/apps/rest_dbus.py
index 605956c..5cb1a56 100644
--- a/module/obmc/wsgi/apps/rest_dbus.py
+++ b/module/obmc/wsgi/apps/rest_dbus.py
@@ -646,8 +646,15 @@ class ImageUploadUtils:
else:
filename = os.path.join(cls.file_loc, filename)
- with open(filename, "w") as fd:
- fd.write(request.body.read())
+ try:
+ file_contents = request.body.read()
+ request.body.close()
+ with open(filename, "w") as fd:
+ fd.write(file_contents)
+ except (IOError, ValueError), e:
+ abort(400, str(e))
+ except:
+ abort(400, "Unexpected Error")
class ImagePostHandler(RouteHandler):
OpenPOWER on IntegriCloud