Created
February 3, 2010 21:41
-
-
Save stympy/294057 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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