Skip to content

Commit

Permalink
fixing object copy/rename operations on key with accents
Browse files Browse the repository at this point in the history
  • Loading branch information
jakimowicz authored and lmarburger committed Nov 17, 2010
1 parent 534ce77 commit c16f4d9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/aws/s3/object.rb
Expand Up @@ -179,7 +179,7 @@ def find(key, bucket = nil)
def copy(key, copy_key, bucket = nil, options = {})
bucket = bucket_name(bucket)
source_key = path!(bucket, key)
default_options = {'x-amz-copy-source' => source_key}
default_options = {'x-amz-copy-source' => URI.escape(source_key)}
target_key = path!(bucket, copy_key)
returning put(target_key, default_options) do
acl(copy_key, bucket, acl(key, bucket)) if options[:copy_acl]
Expand Down
20 changes: 20 additions & 0 deletions test/remote/object_test.rb
Expand Up @@ -176,6 +176,26 @@ def test_object
assert_equal object.value, copy.value
assert_equal object.content_type, copy.content_type

# Test copy to an filename with an accent
copy_to_accent = nil
assert_nothing_raised do
object.copy('testing_s3objects-copy-to-accent-é')
copy_to_accent = S3Object.find('testing_s3objects-copy-to-accent-é', TEST_BUCKET)
assert copy_to_accent
assert_equal copy_to_accent.value, object.value
assert_equal copy_to_accent.content_type, object.content_type
end

# Test copy from an filename with an accent
assert_nothing_raised do
object_with_accent = S3Object.find('testing_s3objects-copy-to-accent-é')
object_with_accent.copy('testing_s3objects-copy-from-accent')
copy_from_accent = S3Object.find('testing_s3objects-copy-from-accent', TEST_BUCKET)
assert copy_from_accent
assert_equal copy_from_accent.value, object_with_accent.value
assert_equal copy_from_accent.content_type, object_with_accent.content_type
end

# Delete object

assert_nothing_raised do
Expand Down

0 comments on commit c16f4d9

Please sign in to comment.