|
import os
ACCESS_KEY_ID = os.environ['ACCESS_KEY_ID']
SECRET_ACCESS_KEY = os.environ['SECRET_ACCESS_KEY']
# SNIP
import boto
def list_all_buckets(s3):
buckets = s3.get_all_buckets()
return buckets
def main():
s3 = boto.connect_s3(
aws_access_key_id=ACCESS_KEY_ID,
aws_secret_access_key=SECRET_ACCESS_KEY)
buckets = list_all_buckets(s3)
for bucket in buckets:
print("First objects from bucket '{}' in location {}:".
format(bucket.name, bucket.get_location()))
for i, obj in enumerate(bucket.list()):
if i > 3:
break
print(" {}".format(repr(obj)))
main()
# SNAP
|