fixes bug698318.
Work done by Ewan Mellor; I just fixed a conflict after merging trunk...
This commit is contained in:
@@ -192,7 +192,7 @@ class Controller(wsgi.Controller):
|
||||
registry.update_image_metadata(image_meta['id'], image_meta)
|
||||
|
||||
try:
|
||||
location = store.add(image_meta['id'], req.body)
|
||||
location = store.add(image_meta['id'], req.body_file)
|
||||
return location
|
||||
except exception.Duplicate, e:
|
||||
logging.error("Error adding image to store: %s", str(e))
|
||||
|
@@ -110,7 +110,7 @@ class FilesystemBackend(glance.store.Backend):
|
||||
FLAGS.filesystem_store_datadir and <ID> is the supplied image ID.
|
||||
|
||||
:param id: The opaque image identifier
|
||||
:param data: The image data to write
|
||||
:param data: The image data to write, as a file-like object
|
||||
|
||||
:retval The location that was written, with file:// scheme prepended
|
||||
"""
|
||||
@@ -125,8 +125,11 @@ class FilesystemBackend(glance.store.Backend):
|
||||
raise exception.Duplicate("Image file %s already exists!"
|
||||
% filepath)
|
||||
|
||||
f = open(filepath, 'wb')
|
||||
f.write(data)
|
||||
f.close()
|
||||
with open(filepath, 'wb') as f:
|
||||
while True:
|
||||
buf = data.read(ChunkedFile.CHUNKSIZE)
|
||||
if not buf:
|
||||
break
|
||||
f.write(buf)
|
||||
|
||||
return 'file://%s' % filepath
|
||||
|
Reference in New Issue
Block a user