views:

264

answers:

3

I have a file contained in a key in my S3 bucket. I want to create a new key, which will contain the same file. Is it possible to do without downloading that file? I'm looking for a solution in Python (and preferably boto library).

+1  A: 

S3 allows object by object copy. The CopyObject operation creates a copy of an object when you specify the key and bucket of a source object and the key and bucket of a target destination. Not sure if boto has a compact implementation.

whatnick
A: 

Browsing through boto's source code I found that the Key object has a "copy" method. Thanks for your suggestion about CopyObject operation.

Thotep
A: 

Where bucket is the destination bucket:

bucket.copy_key(new_key,source_bucket,source_key)
Adam Nelson
This actually reads the key and puts it up in the new bucket - which is not what you want. Sorry.
Adam Nelson