From 15e7b064d3d0c78f968c435da52b1ebb0c0adfb3 Mon Sep 17 00:00:00 2001 From: Mitch Garnaat Date: Mon, 27 Jan 2014 07:34:21 -0800 Subject: [PATCH] Quote the filename in the x-amz-copy-source header for multipart COPY operations. Fixes #614. --- awscli/customizations/s3/tasks.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/awscli/customizations/s3/tasks.py b/awscli/customizations/s3/tasks.py index d187fb105530..0c6ff0b4d284 100644 --- a/awscli/customizations/s3/tasks.py +++ b/awscli/customizations/s3/tasks.py @@ -7,6 +7,7 @@ from botocore.vendored import requests from botocore.exceptions import IncompleteReadError +from botocore.compat import quote from awscli.customizations.s3.utils import find_bucket_key, MD5Error, \ operate, ReadFileChunk, relative_path, IORequest, IOCloseRequest @@ -150,11 +151,13 @@ def __call__(self): upload_id = self._upload_context.wait_for_upload_id() bucket, key = find_bucket_key(self._filename.dest) src_bucket, src_key = find_bucket_key(self._filename.src) + copy_source = '%s/%s' % (src_bucket, src_key) + copy_source = quote(copy_source.encode('utf-8'), safe='/~') params = {'endpoint': self._filename.endpoint, 'bucket': bucket, 'key': key, 'part_number': self._part_number, 'upload_id': upload_id, - 'copy_source': '%s/%s' % (src_bucket, src_key), + 'copy_source': copy_source, 'copy_source_range': range_param} response_data, http = operate( self._filename.service, 'UploadPartCopy', params)