我想在python中下载子文件夹文件

时间:2019-06-02 15:07:45

标签: amazon-s3 boto3 boto

我必须下载MyBucket / bucket1 / bucket1.1 / bucket1.1.2 / application.csv

1 个答案:

答案 0 :(得分:0)

AWS Command-Line Interface (CLI)是调用AWS API命令(包括复制命令)的便捷方法:

aws s3 cp s3://MyBucket/bucket1/bucket1.1/bucket1.1.2/application.csv .

如果您希望通过boto3做到这一点:

import boto3

s3_client = boto3.client('s3', region_name='ap-southeast-2') # Adjust as necessary
response = s3_client.download_file('MyBucket', 'bucket1/bucket1.1/bucket1.1.2/application.csv', '/tmp/application.csv')

请参阅:S3 — Boto 3 documentation