Skip to content

Instantly share code, notes, and snippets.

@nowlinuxing
Last active August 29, 2015 14:18
Show Gist options
  • Save nowlinuxing/83ea2ddc50a968e3df65 to your computer and use it in GitHub Desktop.
Save nowlinuxing/83ea2ddc50a968e3df65 to your computer and use it in GitHub Desktop.
Copy the Amazon S3 objects between two buckets
# AWS SDK v1
require 'aws-sdk'
AWS.config(:access_key_id => 'foo', :secret_access_key => 'bar')
s3 = AWS::S3.new
key = "path/to/src"
s3.buckets['src_bucket'].objects.with_prefix(key).each do |o|
o.copy_to(o.key, bucket_name: "dst_bucket")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment