... | ... |
@@ -262,8 +262,6 @@ class MultiPartUpload(object): |
262 | 262 |
# x-amz-copy-source-if-unmodified-since: time_stamp |
263 | 263 |
# x-amz-copy-source-if-modified-since: time_stamp |
264 | 264 |
headers = { |
265 |
- "x-amz-copy-source": "/%s/%s" % (self.src_uri.bucket(), |
|
266 |
- self.src_uri.object()), |
|
267 | 265 |
"x-amz-copy-source": s3_quote("/%s/%s" % (self.src_uri.bucket(), |
268 | 266 |
self.src_uri.object()), |
269 | 267 |
quote_backslashes=False, |
... | ... |
@@ -303,8 +301,8 @@ class MultiPartUpload(object): |
303 | 303 |
part_xml = "<Part><PartNumber>%i</PartNumber><ETag>%s</ETag></Part>" |
304 | 304 |
for seq, etag in self.parts.items(): |
305 | 305 |
parts_xml.append(part_xml % (seq, etag)) |
306 |
- body = "<CompleteMultipartUpload>%s</CompleteMultipartUpload>" % ( |
|
307 |
- "".join(parts_xml)) |
|
306 |
+ body = "<CompleteMultipartUpload>%s</CompleteMultipartUpload>" \ |
|
307 |
+ % "".join(parts_xml) |
|
308 | 308 |
|
309 | 309 |
headers = {"content-length": str(len(body))} |
310 | 310 |
request = self.s3.create_request( |
... | ... |
@@ -851,30 +851,32 @@ class S3(object): |
851 | 851 |
if extra_headers: |
852 | 852 |
headers.update(extra_headers) |
853 | 853 |
|
854 |
+ headers['x-amz-metadata-directive'] = "COPY" |
|
855 |
+ |
|
856 |
+ # Get size of remote source only if multipart is enabled and that no |
|
857 |
+ # size info was provided |
|
858 |
+ if src_size is None and self.config.enable_multipart: |
|
859 |
+ src_info = self.object_info(src_uri) |
|
860 |
+ src_size = int(src_info["headers"]["content-length"]) |
|
861 |
+ |
|
854 | 862 |
# Multipart decision. Only do multipart copy for remote s3 files |
855 | 863 |
# bigger than the multipart copy threshlod. |
856 |
- if self.config.enable_multipart: |
|
857 |
- # get size of remote src only if multipart is enabled and no size |
|
858 |
- # info was provided |
|
859 |
- if src_size is None: |
|
860 |
- src_info = self.object_info(src_uri) |
|
861 |
- src_size = int(src_info["headers"]["content-length"]) |
|
862 |
- |
|
863 |
- if src_size > self.config.multipart_copy_chunk_size_mb * SIZE_1MB: |
|
864 |
- # Multipart requests are quite different... drop here |
|
865 |
- return self.copy_file_multipart(src_uri, dst_uri, src_size, |
|
864 |
+ |
|
865 |
+ if self.config.enable_multipart and \ |
|
866 |
+ src_size > self.config.multipart_copy_chunk_size_mb * SIZE_1MB: |
|
867 |
+ # Multipart requests are quite different... delegate |
|
868 |
+ response = self.copy_file_multipart(src_uri, dst_uri, src_size, |
|
866 | 869 |
headers, extra_label) |
870 |
+ else: |
|
871 |
+ # Not multipart... direct request |
|
872 |
+ headers['x-amz-copy-source'] = s3_quote( |
|
873 |
+ "/%s/%s" % (src_uri.bucket(), src_uri.object()), |
|
874 |
+ quote_backslashes=False, unicode_output=True) |
|
867 | 875 |
|
868 |
- ## Not multipart... |
|
869 |
- headers['x-amz-copy-source'] = s3_quote("/%s/%s" % (src_uri.bucket(), |
|
870 |
- src_uri.object()), |
|
871 |
- quote_backslashes=False, |
|
872 |
- unicode_output=True) |
|
873 |
- headers['x-amz-metadata-directive'] = "COPY" |
|
876 |
+ request = self.create_request("OBJECT_PUT", uri=dst_uri, |
|
877 |
+ headers=headers) |
|
878 |
+ response = self.send_request(request) |
|
874 | 879 |
|
875 |
- request = self.create_request("OBJECT_PUT", uri=dst_uri, |
|
876 |
- headers=headers) |
|
877 |
- response = self.send_request(request) |
|
878 | 880 |
if response["data"] and getRootTagName(response["data"]) == "Error": |
879 | 881 |
# http://doc.s3.amazonaws.com/proposals/copy.html |
880 | 882 |
# Error during copy, status will be 200, so force error code 500 |