import boto3
s3 = boto3.client('s3')
response = s3.get_bucket_acl(Bucket='your-bucket-name')
# 打印 ACL
print(response['Grants'])
import boto3
from datetime import datetime, timedelta
s3 = boto3.client('s3')
expires_in = 3600 # 预签名 URL 的有效期(秒)
object_name = 'your-object-name'
bucket_name = 'your-bucket-name'
# 生成预签名 URL
url = s3.generate_presigned_post(
Bucket=bucket_name,
Key=object_name,
Fields={
"acl": "public-read",
"Content-Type": "application/octet-stream"
},
ExpiresIn=expires_in,
)
print(url)
import boto3
s3 = boto3.client('s3',
aws_access_key_id='your-access-key',
aws_secret_access_key='your-secret-key')
response = s3.list_buckets()
print(response['Buckets'])
如果以上三种方法都不行,可以尝试重新生成密钥,并检查访问权限是否正确配置。