Boto2

Below example of how to list all containers and files in Swift using Boto and the S3 API. See http://boto.cloudhackers.com/en/latest/s3_tut.html for more information on how to use Boto.

Replace aws_access_key_id and aws_secret_access_key with your S3 API keys

#!/usr/bin/env python

import os
import boto
from boto.s3.connection import S3Connection

if __name__ == "__main__":

    conn = S3Connection(
        aws_access_key_id="AAABBBCCC111222333",
        aws_secret_access_key="333222111CCCBBBAAA",
        port=443,
        host='object.cloud.sdsc.edu',
        is_secure=True,
        calling_format=boto.s3.connection.OrdinaryCallingFormat(),
        debug=0)

    buckets = conn.get_all_buckets()

    for bucket in buckets:
        print("BUCKET NAME: %s" % bucket.name)
        print("FILES:")
        for key in bucket.list():
                print("\t%s" % key.name.encode('utf-8'))