deleteBucket method
Deletes the S3 bucket. All objects (including all object versions and delete markers) in the bucket must be deleted before the bucket itself can be deleted.
Related Resources
Parameter bucket
:
Specifies the bucket being deleted.
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<void> deleteBucket({
required String bucket,
String? expectedBucketOwner,
}) async {
ArgumentError.checkNotNull(bucket, 'bucket');
final headers = <String, String>{
if (expectedBucketOwner != null)
'x-amz-expected-bucket-owner': expectedBucketOwner.toString(),
};
await _protocol.send(
method: 'DELETE',
requestUri: '/${Uri.encodeComponent(bucket)}',
headers: headers,
exceptionFnMap: _exceptionFns,
);
}