Add support for image size in v2 api upload

Some backend stores e.g. RBD, will fail if told to create an
image without a valid size (RBD will fail to write to a zero-size
image). Here we add support to allow the image size to be provided
when doing an upload. The result is that the upload content-length
will be set if available either from checking the supplied file
object or as provided by user.

Closes-Bug: 1220197
Change-Id: Ia1f2ea5680a139750d931591949b3e0058148b4b
This commit is contained in:
Edward Hope-Morley
2013-09-03 12:27:54 +01:00
parent 238e9fffcc
commit 4a41358cea
7 changed files with 135 additions and 9 deletions
+4 -1
View File
@@ -26,8 +26,11 @@ class FakeAPI(object):
self.fixtures = fixtures
self.calls = []
def _request(self, method, url, headers=None, body=None):
def _request(self, method, url, headers=None, body=None,
content_length=None):
call = (method, url, headers or {}, body)
if content_length is not None:
call = tuple(list(call) + [content_length])
self.calls.append(call)
return self.fixtures[url][method]