我可以像这样使用 aws cli 下载 s3 文件夹:
aws s3 cp --recursive s3://bucketname/custom-folder /tmp
但我无法列出 boto3 库中的文件夹文件:
import boto3
s3 = boto3.resource('s3')
bucket = s3.Bucket('my-bucket')
for obj in bucket.objects.all():
print(obj.key)
botocore.exceptions.ClientError: An error occurred (AccessDenied) when calling the ListObjects operation: Access Denied
但是,如果我知道特定路径,我可以下载特定文件,我知道这是因为 bash 命令正常工作:
s3.download_file(Bucket='mybucket',Key='custom-folder/1.gz',Filename='/tmp/1.gz')
我的问题是:
如何在没有读取/列出 S3 存储桶中文件的权限的情况下在 Boto3 中递归下载一个文件夹??????
谢谢!