Created
February 27, 2012 17:14
-
-
Save garnaat/1925584 to your computer and use it in GitHub Desktop.
Dowload all of the keys in an S3 bucket with boto
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
import boto | |
import os | |
def download_keys(bucket_name, dst_dir): | |
""" | |
Very simple example showing how to download all keys in a bucket. | |
Assumes key names don't include path separators. Also assumes that | |
you don't have zillions of objects in the bucket. If you have a lot | |
you would want to get several download operations going in parallel. | |
""" | |
s3 = boto.connect_s3() | |
bucket = s3.lookup(bucket_name) | |
for key in bucket: | |
path = os.path.join(dst_dir, key.name) | |
key.get_contents_to_filename(path) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment