Help Center> Object Storage Service> SDK Reference> iOS> Bucket Management> Obtaining the Location of a Bucket

Obtaining the Location of a Bucket

You can call getBucketLocation to obtain the location of a bucket. Sample code is as follows:

static OBSClient *client;
NSString *endPoint = @"your-endpoint";
NSString *SK = @"*** Provide your Secret Key ***";
NSString *AK = @"*** Provide your Access Key ***";
    
// Initialize identity authentication.
OBSStaticCredentialProvider *credentialProvider = [[OBSStaticCredentialProvider alloc] initWithAccessKey:AK secretKey:SK];
    
//Initialize service configuration.
OBSServiceConfiguration *conf = [[OBSServiceConfiguration alloc] initWithURLString:endPoint credentialProvider:credentialProvider];
    
// Initialize an instance of OBSClient.
client = [[OBSClient alloc] initWithConfiguration:conf];
    
// Obtain a bucket location.
OBSGetBucketLocationRequest *request = [[OBSGetBucketLocationRequest alloc]initWithBucketName:@"bucketname"];
    
[client getBucketLocation:request completionHandler:^(OBSGetBucketLocationResponse *response, NSError *error){
    NSLog(response.configuration.locationConstraint);
}];

When creating a bucket, you can specify its location. For details, see Creating a Bucket.