putObjectLockConfiguration method
- required String bucket,
- String? contentMD5,
- String? expectedBucketOwner,
- ObjectLockConfiguration? objectLockConfiguration,
- RequestPayer? requestPayer,
- String? token,
Places an Object Lock configuration on the specified bucket. The rule specified in the Object Lock configuration will be applied by default to every new object placed in the specified bucket.
Related Resources
Parameter bucket
:
The bucket whose Object Lock configuration you want to create or replace.
Parameter contentMD5
:
The MD5 hash for the request body.
For requests made using the AWS Command Line Interface (CLI) or AWS SDKs, this field is calculated automatically.
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.
Parameter objectLockConfiguration
:
The Object Lock configuration that you want to apply to the specified
bucket.
Parameter token
:
A token to allow Object Lock to be enabled for an existing bucket.
Implementation
Future<PutObjectLockConfigurationOutput> putObjectLockConfiguration({
required String bucket,
String? contentMD5,
String? expectedBucketOwner,
ObjectLockConfiguration? objectLockConfiguration,
RequestPayer? requestPayer,
String? token,
}) async {
ArgumentError.checkNotNull(bucket, 'bucket');
final headers = <String, String>{
if (contentMD5 != null) 'Content-MD5': contentMD5.toString(),
if (expectedBucketOwner != null)
'x-amz-expected-bucket-owner': expectedBucketOwner.toString(),
if (requestPayer != null) 'x-amz-request-payer': requestPayer.toValue(),
if (token != null) 'x-amz-bucket-object-lock-token': token.toString(),
};
final $result = await _protocol.sendRaw(
method: 'PUT',
requestUri: '/${Uri.encodeComponent(bucket)}?object-lock',
headers: headers,
payload: objectLockConfiguration?.toXml('ObjectLockConfiguration'),
exceptionFnMap: _exceptionFns,
);
final $elem = await _s.xmlFromResponse($result);
return PutObjectLockConfigurationOutput(
requestCharged: _s
.extractHeaderStringValue($result.headers, 'x-amz-request-charged')
?.toRequestCharged(),
);
}