deleteObjectAnnotation method
Deletes a specific annotation from an Amazon S3 object. Use the
x-amz-object-if-match header to perform a conditional delete
that only succeeds if the object's ETag matches the provided value,
preventing race conditions during concurrent updates.
Deleting an annotation is permanent. Annotations are not independently versioned, so there is no delete marker or way to recover a deleted annotation.
To use this operation, you must have the
s3:DeleteObjectAnnotation permission. If the object is
protected by Object Lock in governance mode, you must also include the
x-amz-bypass-governance-retention header.
The following operations are related to
DeleteObjectAnnotation:
May throw NoSuchBucket.
May throw NoSuchKey.
Parameter annotationName :
The name of the annotation to delete. Annotation names are UTF-8 encoded
and cannot start with aws or s3
(case-insensitive).
Length Constraints: Minimum length of 1. Maximum length of 512 bytes.
Parameter bucket :
The name of the bucket that contains the object.
Parameter key :
The object key.
Parameter expectedBucketOwner :
The account ID of the expected bucket owner.
Parameter objectIfMatch :
If specified, the operation only succeeds if the object's ETag matches the
provided value.
Parameter versionId :
The version ID of the object.
Implementation
Future<DeleteObjectAnnotationOutput> deleteObjectAnnotation({
required String annotationName,
required String bucket,
required String key,
String? expectedBucketOwner,
String? objectIfMatch,
RequestPayer? requestPayer,
String? versionId,
}) async {
final headers = <String, String>{
if (expectedBucketOwner != null)
'x-amz-expected-bucket-owner': expectedBucketOwner.toString(),
if (objectIfMatch != null)
'x-amz-object-if-match': objectIfMatch.toString(),
if (requestPayer != null) 'x-amz-request-payer': requestPayer.value,
};
final $query = <String, List<String>>{
'annotationName': [annotationName],
if (versionId != null) 'versionId': [versionId],
};
final $result = await _protocol.sendRaw(
method: 'DELETE',
requestUri:
'/${key.split('/').map(Uri.encodeComponent).join('/')}?annotation',
queryParams: $query,
headers: headers,
endpoint: _resolveEndpoint(
bucket: bucket,
),
exceptionFnMap: _exceptionFns,
);
final $elem = await _s.xmlFromResponse($result);
return DeleteObjectAnnotationOutput(
objectVersionId: _s.extractHeaderStringValue(
$result.headers, 'x-amz-object-version-id'),
requestCharged: _s
.extractHeaderStringValue($result.headers, 'x-amz-request-charged')
?.let(RequestCharged.fromString),
);
}