From 5144b77237436c082f802910e670f02291c40b98 Mon Sep 17 00:00:00 2001 From: Antony Chazapis Date: Fri, 30 Sep 2011 11:39:12 +0300 Subject: [PATCH] Container-level block upload. Refs #1371 --- pithos/api/functions.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/pithos/api/functions.py b/pithos/api/functions.py index 9ca161b..5bb83b4 100644 --- a/pithos/api/functions.py +++ b/pithos/api/functions.py @@ -392,7 +392,23 @@ def container_update(request, v_account, v_container): raise Unauthorized('Access denied') except NameError: raise ItemNotFound('Container does not exist') - return HttpResponse(status=202) + + content_length = -1 + if request.META.get('HTTP_TRANSFER_ENCODING') != 'chunked': + content_length = get_int_parameter(request.META.get('CONTENT_LENGTH', 0)) + content_type = request.META.get('Content-Type') + hashmap = [] + if content_type and content_type == 'application/octet-stream' and content_length != 0: + for data in socket_read_iterator(request, content_length, + request.backend.block_size): + # TODO: Raise 408 (Request Timeout) if this takes too long. + # TODO: Raise 499 (Client Disconnect) if a length is defined and we stop before getting this much data. + hashmap.append(request.backend.put_block(data)) + + response = HttpResponse(status=202) + if hashmap: + response.content = '\n'.join(hashmap) + '\n' + return response @api_method('DELETE') def container_delete(request, v_account, v_container): -- 1.7.10.4