Skip to content

Instantly share code, notes, and snippets.

@stympy
Created February 3, 2010 21:41
Show Gist options
  • Save stympy/294057 to your computer and use it in GitHub Desktop.
Save stympy/294057 to your computer and use it in GitHub Desktop.
module AWS
module S3
class Bucket
def copy_to(target)
each do |obj|
returning Base.put("/#{target}/#{obj.key}", { 'x-amz-copy-source' => "/#{name}/#{obj.key}", 'x-amz-metadata-directive' => 'COPY', 'Content-Length' => 0 }) do
S3Object.acl(obj.key, target, S3Object.acl(obj.key, name))
end
end
end
end
end
end
require 'aws/s3'
require 's3_copy_bucket'
AWS::S3::Base.establish_connection! :access_key_id => 'foo', :secret_access_key => 'bar'
src = AWS::S3::Bucket.find('my.source.bucket')
dest = AWS::S3::Bucket.find('my.destination.bucket')
src.copy_to(dest.name)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment