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/10 19:45:43 UTC
svn commit: r1090851 -
/incubator/libcloud/trunk/libcloud/storage/drivers/s3.py
Author: tomaz
Date: Sun Apr 10 17:45:43 2011
New Revision: 1090851
URL: http://svn.apache.org/viewvc?rev=1090851&view=rev
Log:
1. Calculate the request signature in the pre_connect hook
2. Pass Content-MD5 header when the file_hash argument is provided
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=1090851&r1=1090850&r2=1090851&view=diff
==============================================================================
--- incubator/libcloud/trunk/libcloud/storage/drivers/s3.py (original)
+++ incubator/libcloud/trunk/libcloud/storage/drivers/s3.py Sun Apr 10 17:45:43 2011
@@ -80,15 +80,18 @@ class S3Connection(ConnectionUserAndKey)
def add_default_params(self, params):
expires = str(int(time.time()) + EXPIRATION_SECONDS)
+ params['AWSAccessKeyId'] = self.user_id
+ params['Expires'] = expires
+ return params
+
+ def pre_connect_hook(self, params, headers):
params['Signature'] = self._get_aws_auth_param(method=self.method,
- headers={},
+ headers=headers,
params=params,
- expires=expires,
+ expires=params['Expires'],
secret_key=self.key,
path=self.action)
- params['AWSAccessKeyId'] = self.user_id
- params['Expires'] = expires
- return params
+ return params, headers
def _get_aws_auth_param(self, method, headers, params, expires,
secret_key, path='/'):
@@ -323,13 +326,7 @@ class S3StorageDriver(StorageDriver):
meta_data = extra.get('meta_data', None)
if not iterator and file_hash:
- # TODO: This driver also needs to access to the headers in the
- # add_default_params method so the correct signature can be
- # calculated when a MD5 hash is provided.
- # Uncomment this line when we decide what is the best way to handle
- # this.
- #headers['Content-MD5'] = file_hash
- pass
+ headers['Content-MD5'] = base64.b64encode(file_hash.decode('hex'))
if meta_data:
for key, value in meta_data.iteritems():