以下代码用于获取桶的地域(称为Region或Location):
from src.ossConfig import ossConfig
import unicloud_oss.Oss as Oss access_key = 'XXXXXXXXX' secret_key = 'XXXXXXXXXXXXXXXXXXX' endpoint_url = 'http://XXXXXXXXXXXXXXXXX.com' config = ossConfig(access_key,secret_key,endpoint_url) bucket_name = 'test1' bucket_region = Oss.get_bucket_region(config, bucket_name) if bucket_region is None: print('Error!') else: print(f' {bucket_region["LocationConstraint"]}') |