Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'add_mpu_version_and_policy' of https://github.com/tpodo…

…wd/boto into tpodowd-add_mpu_version_and_policy
  • Loading branch information...
commit 41d0b01d63e78e2b1e40a7281b6dda6c992b9807 2 parents a24423a + ac31e30
@garnaat garnaat authored
Showing with 21 additions and 3 deletions.
  1. +17 −3 boto/s3/bucket.py
  2. +4 −0 boto/s3/multipart.py
View
20 boto/s3/bucket.py
@@ -1335,7 +1335,8 @@ def delete_policy(self, headers=None):
def initiate_multipart_upload(self, key_name, headers=None,
reduced_redundancy=False,
- metadata=None, encrypt_key=False):
+ metadata=None, encrypt_key=False,
+ policy=None):
"""
Start a multipart upload operation.
@@ -1366,11 +1367,16 @@ def initiate_multipart_upload(self, key_name, headers=None,
be encrypted on the server-side by S3 and
will be stored in an encrypted form while
at rest in S3.
+
+ :type policy: :class:`boto.s3.acl.CannedACLStrings`
+ :param policy: A canned ACL policy that will be applied to the
+ new key (once completed) in S3.
"""
query_args = 'uploads'
provider = self.connection.provider
- if headers is None:
- headers = {}
+ headers = headers or {}
+ if policy:
+ headers[provider.acl_header] = policy
if reduced_redundancy:
storage_class_header = provider.storage_class_header
if storage_class_header:
@@ -1422,6 +1428,14 @@ def complete_multipart_upload(self, key_name, upload_id,
resp = CompleteMultiPartUpload(self)
h = handler.XmlHandler(resp, self)
xml.sax.parseString(body, h)
+ # Use a dummy key to parse various response headers
+ # for versioning, encryption info and then explicitly
+ # set the completed MPU object values from key.
+ k = self.key_class(self)
+ k.handle_version_headers(response)
+ k.handle_encryption_headers(response)
+ resp.version_id = k.version_id
+ resp.encrypted = k.encrypted
return resp
else:
raise self.connection.provider.storage_response_error(
View
4 boto/s3/multipart.py
@@ -35,6 +35,8 @@ class CompleteMultiPartUpload(object):
is contained
* key_name - The name of the new, completed key
* etag - The MD5 hash of the completed, combined upload
+ * version_id - The version_id of the completed upload
+ * encrypted - The value of the encryption header
"""
def __init__(self, bucket=None):
@@ -43,6 +45,8 @@ def __init__(self, bucket=None):
self.bucket_name = None
self.key_name = None
self.etag = None
+ self.version_id = None
+ self.encrypted = None
def __repr__(self):
return '<CompleteMultiPartUpload: %s.%s>' % (self.bucket_name,
Please sign in to comment.
Something went wrong with that request. Please try again.