python3 boto3 修改 s3对象存储 属性

  1. 修改单个文件的属性见这里
 import boto3
import botocore
from botocore.config import Config
from botocore.exceptions import ClientError
import yaml
from loguru import logger
#构建s3连接client
s3_client = boto3.client(
                's3',
                aws_access_key_id='yourkey',
                aws_secret_access_key='yourpasswd',
                endpoint_url='http://test.com/cn',
                verify=False,
                #这里将连接超时设置为10秒,并最大重试次数设置为5次
                config=Config(connect_timeout=10, retries={'max_attempts': 5}))
#改变某个文件为公开读                
s3_client.put_object_acl(ACL='public-read', Bucket='yourbucket', Key='yourfile')

  1. S3 Boto3 python - 将所有文件acl更改为public read, 见这里

你可能感兴趣的:(python,aws,对象存储)