getBucketLocation method
Returns the Region the bucket resides in. You set the bucket's Region
using the LocationConstraint
request parameter in a
CreateBucket
request. For more information, see CreateBucket.
To use this implementation of the operation, you must be the bucket owner.
The following operations are related to GetBucketLocation
:
Parameter bucket
:
The name of the bucket for which to get the location.
Parameter expectedBucketOwner
:
The account id of the expected bucket owner. If the bucket is owned by a
different account, the request will fail with an HTTP 403 (Access
Denied)
error.
Implementation
Future<GetBucketLocationOutput> getBucketLocation({
required String bucket,
String? expectedBucketOwner,
}) async {
ArgumentError.checkNotNull(bucket, 'bucket');
final headers = <String, String>{
if (expectedBucketOwner != null)
'x-amz-expected-bucket-owner': expectedBucketOwner.toString(),
};
final $result = await _protocol.send(
method: 'GET',
requestUri: '/${Uri.encodeComponent(bucket)}?location',
headers: headers,
exceptionFnMap: _exceptionFns,
);
return GetBucketLocationOutput.fromXml($result.body);
}