deleteBucketPolicy method

Future<void> deleteBucketPolicy({
  1. required String bucket,
  2. String? expectedBucketOwner,
})

This implementation of the DELETE operation uses the policy subresource to delete the policy of a specified bucket. If you are using an identity other than the root user of the AWS account that owns the bucket, the calling identity must have the DeleteBucketPolicy permissions on the specified bucket and belong to the bucket owner's account to use this operation.

If you don't have DeleteBucketPolicy permissions, Amazon S3 returns a 403 Access Denied error. If you have the correct permissions, but you're not using an identity that belongs to the bucket owner's account, Amazon S3 returns a 405 Method Not Allowed error. For more information about bucket policies, see Using Bucket Policies and UserPolicies.

The following operations are related to DeleteBucketPolicy

Parameter bucket : The bucket name.

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> deleteBucketPolicy({
  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)}?policy',
    headers: headers,
    exceptionFnMap: _exceptionFns,
  );
}