The aws-s3 documentation says:
# Copying an object
S3Object.copy 'headshot.jpg', 'headshot2.jpg', 'photos'
But how do I copy heashot.jpg
from the photos
bucket to the archive
bucket for example
Thanks!
Deb
The aws-s3 documentation says:
# Copying an object
S3Object.copy 'headshot.jpg', 'headshot2.jpg', 'photos'
But how do I copy heashot.jpg
from the photos
bucket to the archive
bucket for example
Thanks!
Deb
I believe that in order to copy between buckets you must read the file's contents from the source bucket and then write it back to the destination bucket via your application's memory space. There's a snippet showing this using aws-s3
here and another approach using right_aws
here
Using the right_aws
gem:
# With s3 being an S3 object acquired via S3Interface.new
# Copies key1 from bucket b1 to key1_copy in bucket b2:
s3.copy('b1', 'key1', 'b2', 'key1_copy')
the gotcha I ran into is that if you have pics/1234/yourfile.jpg
the bucket
is only pics
and the key
is 1234/yourfile.jpg
I got the answer from here: http://stackoverflow.com/questions/769848/how-do-i-copy-files-between-buckets-using-s3-from-a-rails-application