diff --git a/ds3/ds3.py b/ds3/ds3.py index fcf7cbc..762044b 100755 --- a/ds3/ds3.py +++ b/ds3/ds3.py @@ -7947,15 +7947,18 @@ def process_response(self, response): class GetObjectResponse(AbstractResponse): + def __init__(self, response, request, buffer_size=None): + self.buffer_size = buffer_size + super(GetObjectResponse, self).__init__(response, request) def process_response(self, response): self.__check_status_codes__([200, 206]) stream = self.request.stream try: - bytes_read = response.read() + bytes_read = response.read(self.buffer_size) while bytes_read: stream.write(bytes_read) - bytes_read = response.read() + bytes_read = response.read(self.buffer_size) finally: stream.close() response.close() @@ -11243,10 +11246,10 @@ def get_service(self, request): raise TypeError('request for get_service should be of type GetServiceRequest but was ' + request.__class__.__name__) return GetServiceResponse(self.net_client.get_response(request), request) - def get_object(self, request): + def get_object(self, request, buffer_size=1048576): if not isinstance(request, GetObjectRequest): raise TypeError('request for get_object should be of type GetObjectRequest but was ' + request.__class__.__name__) - return GetObjectResponse(self.net_client.get_response(request), request) + return GetObjectResponse(self.net_client.get_response(request), request, buffer_size) def head_bucket(self, request): if not isinstance(request, HeadBucketRequest):