【发布时间】:2017-12-08 11:35:48
【问题描述】:
我正在使用以下代码将我的所有文件下载到 s3 存储桶中:
def main(bucket_name, destination_dir):
bucket = boto3.resource('s3').Bucket(bucket_name)
for obj in bucket.objects.all():
if obj.key.endswith('/'):
continue
destination = '%s/%s' % (bucket_name, obj.key)
if not os.path.exists(destination):
os.makedirs(os.path.dirname(destination), exist_ok=True)
bucket.download_file(obj.key, destination)
如果可能的话,我想知道如何使这个异步。
提前谢谢你。
【问题讨论】:
标签: python-3.x amazon-s3 boto boto3