【发布时间】:2021-10-15 23:48:28
【问题描述】:
我在 S3 存储桶中有一堆文件,它们都需要公开。但是,当我的队友在那里添加新文件时,他们忘记将它们设置为公开。
所以,我使用 python3 脚本来确保所有相应的文件都被公开。
这是我目前所拥有的:
import boto3
s3 = boto3.resource('s3', region_name='eu-west-1')
## Bucket to use
bucket = s3.Bucket('my_bucket')
## List objects within a given prefix
for obj in bucket.objects.filter(Delimiter='/', Prefix='public_folder/'):
obj.set_acl('public-read')
当我尝试上述方法时,我得到一个错误:
AttributeError: 's3.ObjectSummary' object has no attribute 'set_acl'
我该怎么做?
【问题讨论】:
标签: python python-3.x amazon-web-services amazon-s3 boto3