Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(476)

Unified Diff: third_party/gsutil/boto/boto/s3/multipart.py

Issue 10199002: Upgrade gsutil to 3.4 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed comments Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/gsutil/boto/boto/s3/multidelete.py ('k') | third_party/gsutil/boto/boto/s3/prefix.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/gsutil/boto/boto/s3/multipart.py
diff --git a/third_party/gsutil/20110627/boto/boto/s3/multipart.py b/third_party/gsutil/boto/boto/s3/multipart.py
similarity index 84%
rename from third_party/gsutil/20110627/boto/boto/s3/multipart.py
rename to third_party/gsutil/boto/boto/s3/multipart.py
index 8befc5eaee1fa5957ac2c8a6dabe38390e514663..a293033390c19af6551d296f8c9c12214b50313b 100644
--- a/third_party/gsutil/20110627/boto/boto/s3/multipart.py
+++ b/third_party/gsutil/boto/boto/s3/multipart.py
@@ -38,7 +38,7 @@ class CompleteMultiPartUpload(object):
"""
def __init__(self, bucket=None):
- self.bucket = None
+ self.bucket = bucket
self.location = None
self.bucket_name = None
self.key_name = None
@@ -142,7 +142,6 @@ class MultiPartUpload(object):
return part_lister(self)
def to_xml(self):
- self.get_all_parts()
s = '<CompleteMultipartUpload>\n'
for part in self:
s += ' <Part>\n'
@@ -185,6 +184,8 @@ class MultiPartUpload(object):
self.is_truncated = True
else:
self.is_truncated = False
+ elif name == 'Initiated':
+ self.initiated = value
else:
setattr(self, name, value)
@@ -199,7 +200,7 @@ class MultiPartUpload(object):
self._parts = []
query_args = 'uploadId=%s' % self.id
if max_parts:
- query_args += '&max_parts=%d' % max_parts
+ query_args += '&max-parts=%d' % max_parts
if part_number_marker:
query_args += '&part-number-marker=%s' % part_number_marker
response = self.bucket.connection.make_request('GET', self.bucket.name,
@@ -212,7 +213,8 @@ class MultiPartUpload(object):
return self._parts
def upload_part_from_file(self, fp, part_num, headers=None, replace=True,
- cb=None, num_cb=10, policy=None, md5=None):
+ cb=None, num_cb=10, policy=None, md5=None,
+ size=None):
"""
Upload another part of this MultiPart Upload.
@@ -231,7 +233,41 @@ class MultiPartUpload(object):
key = self.bucket.new_key(self.key_name)
key.set_contents_from_file(fp, headers, replace, cb, num_cb, policy,
md5, reduced_redundancy=False,
- query_args=query_args)
+ query_args=query_args, size=size)
+
+ def copy_part_from_key(self, src_bucket_name, src_key_name, part_num,
+ start=None, end=None):
+ """
+ Copy another part of this MultiPart Upload.
+
+ :type src_bucket_name: string
+ :param src_bucket_name: Name of the bucket containing the source key
+
+ :type src_key_name: string
+ :param src_key_name: Name of the source key
+
+ :type part_num: int
+ :param part_num: The number of this part.
+
+ :type start: int
+ :param start: Zero-based byte offset to start copying from
+
+ :type end: int
+ :param end: Zero-based byte offset to copy to
+ """
+ if part_num < 1:
+ raise ValueError('Part numbers must be greater than zero')
+ query_args = 'uploadId=%s&partNumber=%d' % (self.id, part_num)
+ if start is not None and end is not None:
+ rng = 'bytes=%s-%s' % (start, end)
+ provider = self.bucket.connection.provider
+ headers = {provider.copy_source_range_header: rng}
+ else:
+ headers = None
+ return self.bucket.copy_key(self.key_name, src_bucket_name,
+ src_key_name, storage_class=None,
+ headers=headers,
+ query_args=query_args)
def complete_upload(self):
"""
« no previous file with comments | « third_party/gsutil/boto/boto/s3/multidelete.py ('k') | third_party/gsutil/boto/boto/s3/prefix.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698