You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by to...@apache.org on 2011/04/09 15:52:03 UTC
svn commit: r1090596 -
/incubator/libcloud/trunk/libcloud/storage/drivers/s3.py
Author: tomaz
Date: Sat Apr 9 13:52:03 2011
New Revision: 1090596
URL: http://svn.apache.org/viewvc?rev=1090596&view=rev
Log:
Add download_object_as_stream method to the S3 driver.
Modified:
incubator/libcloud/trunk/libcloud/storage/drivers/s3.py
Modified: incubator/libcloud/trunk/libcloud/storage/drivers/s3.py
URL: http://svn.apache.org/viewvc/incubator/libcloud/trunk/libcloud/storage/drivers/s3.py?rev=1090596&r1=1090595&r2=1090596&view=diff
==============================================================================
--- incubator/libcloud/trunk/libcloud/storage/drivers/s3.py (original)
+++ incubator/libcloud/trunk/libcloud/storage/drivers/s3.py Sat Apr 9 13:52:03 2011
@@ -24,6 +24,7 @@ from hashlib import sha1
from xml.etree.ElementTree import Element, SubElement, tostring
from libcloud.utils import fixxpath, findtext, in_development_warning
+from libcloud.utils import read_in_chunks
from libcloud.common.types import InvalidCredsError, LibcloudError
from libcloud.common.base import ConnectionUserAndKey
from libcloud.common.aws import AWSBaseResponse
@@ -236,11 +237,25 @@ class S3StorageDriver(StorageDriver):
return self._get_object(obj=obj, callback=self._save_object,
response=response,
callback_kwargs={'obj': obj,
+ 'response': response.response,
'destination_path': destination_path,
'overwrite_existing': overwrite_existing,
'delete_on_failure': delete_on_failure},
success_status_code=httplib.OK)
+ def download_object_as_stream(self, obj, chunk_size=None):
+ container_name = self._clean_name(obj.container.name)
+ object_name = self._clean_name(obj.name)
+ response = self.connection.request('/%s/%s' % (container_name,
+ object_name),
+ method='GET', raw=True)
+
+ return self._get_object(obj=obj, callback=read_in_chunks,
+ response=response,
+ callback_kwargs={ 'iterator': response.response,
+ 'chunk_size': chunk_size},
+ success_status_code=httplib.OK)
+
def delete_object(self, obj):
object_name = self._clean_name(name=obj.name)
response = self.connection.request('/%s/%s' % (obj.container.name,