зеркало из https://github.com/github/aws-s3.git
Replace ad-hoc S3Object.copy method with newly support built in API call.
This commit is contained in:
Родитель
9eb15be0ad
Коммит
db13e585c6
|
@ -0,0 +1 @@
|
|||
.rake_tasks
|
|
@ -1,5 +1,7 @@
|
|||
trunk:
|
||||
|
||||
- Replace ad-hoc S3Object.copy method with newly support built in API call.
|
||||
|
||||
- Do not make connections persistent by default. This "feature" causes far more broken pipes than it is worth. Use with caution.
|
||||
|
||||
0.4.0:
|
||||
|
|
|
@ -178,13 +178,15 @@ module AWS
|
|||
end
|
||||
end
|
||||
|
||||
# Makes a copy of the object with <tt>key</tt> to <tt>copy_name</tt>.
|
||||
# Makes a copy of the object with <tt>key</tt> to <tt>copy_key</tt>, preserving the ACL of the existing object if the <tt>:copy_acl</tt> option is true (default false).
|
||||
def copy(key, copy_key, bucket = nil, options = {})
|
||||
bucket = bucket_name(bucket)
|
||||
original = open(url_for(key, bucket))
|
||||
default_options = {:content_type => original.content_type}
|
||||
store(copy_key, original, bucket, default_options.merge(options))
|
||||
acl(copy_key, bucket, acl(key, bucket))
|
||||
source_key = path!(bucket, key)
|
||||
default_options = {'x-amz-copy-source' => 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]
|
||||
end
|
||||
end
|
||||
|
||||
# Rename the object with key <tt>from</tt> to have key in <tt>to</tt>.
|
||||
|
|
|
@ -315,7 +315,7 @@ class RemoteS3ObjectTest < Test::Unit::TestCase
|
|||
S3Object.delete('name with spaces', TEST_BUCKET)
|
||||
end
|
||||
|
||||
def test_copying_an_object_should_copy_over_its_acl_also
|
||||
def test_copying_an_object_should_copy_over_its_acl_also_if_requested
|
||||
key = 'copied-objects-inherit-acl'
|
||||
copy_key = key + '2'
|
||||
S3Object.store(key, 'value does not matter', TEST_BUCKET)
|
||||
|
@ -328,7 +328,7 @@ class RemoteS3ObjectTest < Test::Unit::TestCase
|
|||
acl = S3Object.acl(key, TEST_BUCKET)
|
||||
assert_equal 3, acl.grants.size
|
||||
|
||||
S3Object.copy(key, copy_key, TEST_BUCKET)
|
||||
S3Object.copy(key, copy_key, TEST_BUCKET, :copy_acl => true)
|
||||
copied_object = S3Object.find(copy_key, TEST_BUCKET)
|
||||
assert_equal acl.grants, copied_object.acl.grants
|
||||
ensure
|
||||
|
|
Загрузка…
Ссылка в новой задаче