Created
July 1, 2014 01:10
-
-
Save strukturedkaos/afc2a81305af5e3cc285 to your computer and use it in GitHub Desktop.
Copy files between AWS S3 buckets
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
s3.buckets['kickdrop-production-assets'].objects['uploads/'].copy_to('uploads/', :bucket_name => 'kickdrop-staging-assets') | |
source_bucket='kickdrop-production-assets' | |
target_bucket='kickdrop-staging-assets' | |
source_key = 'uploads' | |
target_key = 'uploads' | |
bucket1 = s3.buckets[source_bucket] | |
bucket2 = s3.buckets[target_bucket] | |
obj1 = bucket1.objects.with_prefix("uploads") | |
obj2 = bucket2.objects.with_prefix("uploads") | |
target_bucket='kickdrop-staging-assets' | |
bucket1.objects.with_prefix("uploads").each do |object| | |
obj2 = bucket2.objects.with_prefix("uploads")[object.key] | |
object.copy_to(obj2, bucket_name: 'target_bucket', acl: :public_read) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment