getBucketRegion method
Gets the region of bucket
. The region is cached for subsequent calls.
Implementation
Future<String> getBucketRegion(String bucket) async {
MinioInvalidBucketNameError.check(bucket);
if (region != null) {
return region!;
}
if (_regionMap.containsKey(bucket)) {
return _regionMap[bucket]!;
}
final resp = await _client.request(
method: 'GET',
bucket: bucket,
region: 'us-east-1',
queries: <String, dynamic>{'location': null},
);
validate(resp);
final node = xml.XmlDocument.parse(resp.body);
var location = node.findAllElements('LocationConstraint').first.text;
// if (location == null || location.isEmpty) {
if (location.isEmpty) {
location = 'us-east-1';
}
_regionMap[bucket] = location;
return location;
}