Permalink
Browse files

Make sure key name in x-amz-copy-source HTTP header is properly quote…

…d. Fixes issue 306
  • Loading branch information...
1 parent a6c1d1c commit bd35cacff31babec3e24bfdaf46adc4cb8547fb1 Mitch.Garnaat committed Dec 21, 2009
Showing with 3 additions and 2 deletions.
  1. +3 −2 boto/s3/bucket.py
View
@@ -264,12 +264,13 @@ def copy_key(self, new_key_name, src_bucket_name, src_key_name, metadata=None):
:rtype: :class:`boto.s3.key.Key` or subclass
:returns: An instance of the newly created key object
"""
+ src = '%s/%s' % (src_bucket_name, urllib.quote(src_key_name))
if metadata:
- headers = {'x-amz-copy-source' : '%s/%s' % (src_bucket_name, src_key_name),
+ headers = {'x-amz-copy-source' : src,
'x-amz-metadata-directive' : 'REPLACE'}
headers = boto.utils.merge_meta(headers, metadata)
else:
- headers = {'x-amz-copy-source' : '%s/%s' % (src_bucket_name, src_key_name),
+ headers = {'x-amz-copy-source' : src,
'x-amz-metadata-directive' : 'COPY'}
response = self.connection.make_request('PUT', self.name, new_key_name,
headers=headers)

0 comments on commit bd35cac

Please sign in to comment.