且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从带有boto3的AWS S3存储桶下载文件导致ClientError:发生错误(403):禁止

更新时间:2022-11-06 20:01:16

下载文件时,您还需要传递存储区.尝试使用CLI配置region或在创建客户端时通过region_name.

You'll need to pass the bucket region as well when downloading the file. Try configuring region using the CLI or pass region_name when creating the client.

s3 = boto3.client('s3',
    aws_access_key_id=ACCESS_KEY_ID,
    aws_secret_access_key=ACCESS_KEY,
    region_name=AWS_REGION)

https://boto3.amazonaws.com/v1/documentation/api/latest/guide/quickstart.html