查看Bucket所属的区域
更新时间:2022-10-08
查看Bucket所属的区域
Bucket Location即Bucket Region,百度智能云支持的各region详细信息可参见区域选择说明。
如下代码可以获取该Bucket的Location信息:
Client client (ak, sk, config);
ListBucketsRequest listBucketsRequest;
ListBucketsResponse listBucketsResponse;
int ret = client.list_buckets(listBucketsRequest, &listBucketsResponse)
std::vector<BucketSummary> bucketSummaryList = listBucketsResponse.buckets();
if (listBucketsResponse.is_fail()) {
printf("error-message:%s\n", listBucketsResponse.error().message().c_str());
return ;
}
for(const BucketSummary& bs : bucketSummaryList){
std::cout << "name: " << bs.name <<
" location: " << bs.location << std::endl;
}
GetBucketLocationRequest getBucketLocationRequest("bucketName");
GetBucketLocationResponse getBucketLocationResponse;
ret = client.get_bucket_location(getBucketLocationRequest,
&getBucketLocationResponse);
if (getBucketLocationResponse.is_fail()) {
printf("error-message:%s\n", response.error().message().c_str());
return;
}
std::cout << "location: " << getBucketLocationResponse.location() << std::endl;