gpt4 book ai didi

python - Boto 获取 s3 存储桶位置

转载 作者:太空狗 更新时间:2023-10-30 02:43:02 24 4
gpt4 key购买 nike

是否可以使用 boto API 在 s3 中获取存储桶位置?

我说的是来自 AWS API 的这个函数 - http://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketGETlocation.html

提前致谢。

最佳答案

对于 boto3,您可以使用 get_bucket_location 方法,它将返回给您以下之一(截至 2019 年 11 月):

'EU'|'eu-west-1'|'us-west-1'|'us-west-2'|'ap-south-1'|'ap-southeast-1'|'ap- southeast-2'|'ap-northeast-1'|'sa-east-1'|'cn-north-1'|'eu-central-1'

示例方法如下所示:

def get_location(client, bucket_name):
response = client.get_bucket_location(Bucket=bucket_name)
return response['LocationConstraint']

参见 documentation for more info .

关于python - Boto 获取 s3 存储桶位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34811146/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com