Implement download_object_as_stream.

Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/f63f0bba
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/f63f0bba
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/f63f0bba

Branch: refs/heads/trunk
Commit: f63f0bba776a6e463f057dcfd382c6556265bfcd
Parents: 03e52b8
Author: Tomaz Muraus <[email protected]>
Authored: Sun Dec 20 13:00:08 2015 +0100
Committer: Tomaz Muraus <[email protected]>
Committed: Sun Jan 10 16:54:38 2016 +0100

----------------------------------------------------------------------
 libcloud/storage/drivers/backblaze_b2.py | 10 ++++++++++
 1 file changed, 10 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/f63f0bba/libcloud/storage/drivers/backblaze_b2.py
----------------------------------------------------------------------
diff --git a/libcloud/storage/drivers/backblaze_b2.py 
b/libcloud/storage/drivers/backblaze_b2.py
index 2be6ffc..e27ed72 100644
--- a/libcloud/storage/drivers/backblaze_b2.py
+++ b/libcloud/storage/drivers/backblaze_b2.py
@@ -243,6 +243,16 @@ class BackblazeB2StorageDriver(StorageDriver):
                                 },
                                 success_status_code=httplib.OK)
 
+    def download_object_as_stream(self, obj, chunk_size=None):
+        action = obj.container.name + '/' + obj.name
+        response = self.connection.request(action=action, 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):
         data = {}
         data['fileName'] = obj.name

Reply via email to