libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject svn commit: r1384955 - in /libcloud/trunk: CHANGES libcloud/storage/drivers/s3.py libcloud/test/storage/test_s3.py
Date Fri, 14 Sep 2012 22:36:29 GMT
Author: tomaz
Date: Fri Sep 14 22:36:29 2012
New Revision: 1384955

URL: http://svn.apache.org/viewvc?rev=1384955&view=rev
Log:
Include 'last_modified' and 'content_type' attribute in the Object
'extra' dictionary when retrieving object using get_object in the S3
driver. Also modify 'meta_data' dictionary to include all the
headers prefixed with 'x-amz-meta-'.

Modified:
    libcloud/trunk/CHANGES
    libcloud/trunk/libcloud/storage/drivers/s3.py
    libcloud/trunk/libcloud/test/storage/test_s3.py

Modified: libcloud/trunk/CHANGES
URL: http://svn.apache.org/viewvc/libcloud/trunk/CHANGES?rev=1384955&r1=1384954&r2=1384955&view=diff
==============================================================================
--- libcloud/trunk/CHANGES (original)
+++ libcloud/trunk/CHANGES Fri Sep 14 22:36:29 2012
@@ -1,5 +1,15 @@
                                    -*- coding: utf-8 -*-
 
+Changes with Apache Libcloud in development:
+
+  *) Storage
+
+    - Include 'last_modified' and 'content_type' attribute in the Object
+      'extra' dictionary when retrieving object using get_object in the S3
+      driver. Also modify 'meta_data' dictionary to include all the headers
+      prefixed with 'x-amz-meta-'.
+      [Tomaz Muraus]
+
 Changes with Apache Libcloud 0.11.2:
 
   *) General

Modified: libcloud/trunk/libcloud/storage/drivers/s3.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/storage/drivers/s3.py?rev=1384955&r1=1384954&r2=1384955&view=diff
==============================================================================
--- libcloud/trunk/libcloud/storage/drivers/s3.py (original)
+++ libcloud/trunk/libcloud/storage/drivers/s3.py Fri Sep 14 22:36:29 2012
@@ -460,11 +460,22 @@ class S3StorageDriver(StorageDriver):
         return container
 
     def _headers_to_object(self, object_name, container, headers):
-        meta_data = {'content_type': headers['content-type']}
         hash = headers['etag'].replace('"', '')
+        extra = {'content_type': headers['content-type'], 'etag': headers['etag']}
+        meta_data = {}
+
+        if 'last-modified' in headers:
+            extra['last_modified'] = headers['last-modified']
+
+        for key, value in headers.items():
+            if not key.lower().startswith('x-amz-meta-'):
+                continue
+
+            key = key.replace('x-amz-meta-', '')
+            meta_data[key] = value
 
         obj = Object(name=object_name, size=headers['content-length'],
-                     hash=hash, extra=None,
+                     hash=hash, extra=extra,
                      meta_data=meta_data,
                      container=container,
                      driver=self)

Modified: libcloud/trunk/libcloud/test/storage/test_s3.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/test/storage/test_s3.py?rev=1384955&r1=1384954&r2=1384955&view=diff
==============================================================================
--- libcloud/trunk/libcloud/test/storage/test_s3.py (original)
+++ libcloud/trunk/libcloud/test/storage/test_s3.py Fri Sep 14 22:36:29 2012
@@ -101,7 +101,9 @@ class S3MockHttp(StorageMockHttp):
         body = self.fixtures.load('list_containers.xml')
         headers = {'content-type': 'application/zip',
                     'etag': '"e31208wqsdoj329jd"',
+                    'x-amz-meta-rabbits': 'monkeys',
                     'content-length': 12345,
+                    'last-modified': 'Thu, 13 Sep 2012 07:13:22 GMT'
                     }
 
         return (httplib.OK,
@@ -375,6 +377,9 @@ class S3Tests(unittest.TestCase):
         self.assertEqual(obj.container.name, 'test2')
         self.assertEqual(obj.size, 12345)
         self.assertEqual(obj.hash, 'e31208wqsdoj329jd')
+        self.assertEqual(obj.extra['last_modified'], 'Thu, 13 Sep 2012 07:13:22 GMT')
+        self.assertEqual(obj.extra['content_type'], 'application/zip')
+        self.assertEqual(obj.meta_data['rabbits'], 'monkeys')
 
     def test_create_container_invalid_name(self):
         # invalid container name



Mime
View raw message