getBucketCors method
Returns the cors configuration information set for the bucket.
To use this operation, you must have permission to perform the s3:GetBucketCORS action. By default, the bucket owner has this permission and can grant it to others.
For more information about cors, see Enabling Cross-Origin Resource Sharing.
The following operations are related to GetBucketCors
:
Parameter bucket
:
The bucket name for which to get the cors configuration.
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<GetBucketCorsOutput> getBucketCors({
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)}?cors',
headers: headers,
exceptionFnMap: _exceptionFns,
);
return GetBucketCorsOutput.fromXml($result.body);
}