from boto.s3.connection import S3Connection
conn = S3Connection() # assumes boto.cfg setup
bucket = conn.get_bucket('bucket_name')
for obj in bucket.get_all_keys():
print(obj.key)
在Python 3中:
from boto3 import client
conn = client('s3') # again assumes boto.cfg setup, assume AWS S3
for key in conn.list_objects(Bucket='bucket_name')['Contents']:
print(key['Key'])
这类似于“ls”,但它不考虑前缀文件夹约定,并将列出bucket中的对象。它留给读者过滤掉作为键名一部分的前缀。
在Python 2中:
在Python 3中:
我假设您已经分别配置了身份验证。
查看内容的一种方法是:
相关问题 更多 >
编程相关推荐