python - How to move files between two Amazon S3 Buckets using boto? -


i have move files between 1 bucket pyhton boto api. (i need "cut" file first bucket , "paste" in second one). best way that?

** note: matter if have 2 different access keys , secret keys?

i think boto s3 documentation answers question.

https://github.com/boto/boto/blob/develop/docs/source/s3_tut.rst

moving files 1 bucket via boto copy of keys source destination removing key source.

you can access buckets:

import boto  c = boto.connect_s3() src = c.get_bucket('my_source_bucket') dst = c.get_bucket('my_destination_bucket') 

and iterate keys:

for k in src.list():     # copy stuff destination here     dst.copy_key(k.key.name, src, k.key.name)     # delete source key     k.delete() 

see also: is possible copy files 1 s3 bucket s3cmd?


Comments

Popular posts from this blog

c# - Update a combobox from a presenter (MVP) -

How to understand 2 main() functions after using uftrace to profile the C++ program? -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -