putObject method
Future<PutObjectOutput>
putObject({
- required String bucket,
- required String key,
- ObjectCannedACL? acl,
- Uint8List? body,
- bool? bucketKeyEnabled,
- String? cacheControl,
- ChecksumAlgorithm? checksumAlgorithm,
- String? checksumCRC32,
- String? checksumCRC32C,
- String? checksumCRC64NVME,
- String? checksumMD5,
- String? checksumSHA1,
- String? checksumSHA256,
- String? checksumSHA512,
- String? checksumXXHASH128,
- String? checksumXXHASH3,
- String? checksumXXHASH64,
- String? contentDisposition,
- String? contentEncoding,
- String? contentLanguage,
- int? contentLength,
- String? contentMD5,
- String? contentType,
- String? expectedBucketOwner,
- String? expires,
- String? grantFullControl,
- String? grantRead,
- String? grantReadACP,
- String? grantWriteACP,
- String? ifMatch,
- String? ifNoneMatch,
- Map<
String, String> ? metadata, - ObjectLockLegalHoldStatus? objectLockLegalHoldStatus,
- ObjectLockMode? objectLockMode,
- DateTime? objectLockRetainUntilDate,
- RequestPayer? requestPayer,
- String? sSECustomerAlgorithm,
- String? sSECustomerKey,
- String? sSECustomerKeyMD5,
- String? sSEKMSEncryptionContext,
- String? sSEKMSKeyId,
- ServerSideEncryption? serverSideEncryption,
- StorageClass? storageClass,
- String? tagging,
- String? websiteRedirectLocation,
- int? writeOffsetBytes,
Implementation
Future<PutObjectOutput> putObject({
required String bucket,
required String key,
ObjectCannedACL? acl,
Uint8List? body,
bool? bucketKeyEnabled,
String? cacheControl,
ChecksumAlgorithm? checksumAlgorithm,
String? checksumCRC32,
String? checksumCRC32C,
String? checksumCRC64NVME,
String? checksumMD5,
String? checksumSHA1,
String? checksumSHA256,
String? checksumSHA512,
String? checksumXXHASH128,
String? checksumXXHASH3,
String? checksumXXHASH64,
String? contentDisposition,
String? contentEncoding,
String? contentLanguage,
int? contentLength,
String? contentMD5,
String? contentType,
String? expectedBucketOwner,
String? expires,
String? grantFullControl,
String? grantRead,
String? grantReadACP,
String? grantWriteACP,
String? ifMatch,
String? ifNoneMatch,
Map<String, String>? metadata,
ObjectLockLegalHoldStatus? objectLockLegalHoldStatus,
ObjectLockMode? objectLockMode,
DateTime? objectLockRetainUntilDate,
RequestPayer? requestPayer,
String? sSECustomerAlgorithm,
String? sSECustomerKey,
String? sSECustomerKeyMD5,
String? sSEKMSEncryptionContext,
String? sSEKMSKeyId,
ServerSideEncryption? serverSideEncryption,
StorageClass? storageClass,
String? tagging,
String? websiteRedirectLocation,
int? writeOffsetBytes,
}) async {
final headers = <String, String>{
if (acl != null) 'x-amz-acl': acl.value,
if (bucketKeyEnabled != null)
'x-amz-server-side-encryption-bucket-key-enabled':
bucketKeyEnabled.toString(),
if (cacheControl != null) 'Cache-Control': cacheControl.toString(),
if (checksumAlgorithm != null)
'x-amz-sdk-checksum-algorithm': checksumAlgorithm.value,
if (checksumCRC32 != null)
'x-amz-checksum-crc32': checksumCRC32.toString(),
if (checksumCRC32C != null)
'x-amz-checksum-crc32c': checksumCRC32C.toString(),
if (checksumCRC64NVME != null)
'x-amz-checksum-crc64nvme': checksumCRC64NVME.toString(),
if (checksumMD5 != null) 'x-amz-checksum-md5': checksumMD5.toString(),
if (checksumSHA1 != null) 'x-amz-checksum-sha1': checksumSHA1.toString(),
if (checksumSHA256 != null)
'x-amz-checksum-sha256': checksumSHA256.toString(),
if (checksumSHA512 != null)
'x-amz-checksum-sha512': checksumSHA512.toString(),
if (checksumXXHASH128 != null)
'x-amz-checksum-xxhash128': checksumXXHASH128.toString(),
if (checksumXXHASH3 != null)
'x-amz-checksum-xxhash3': checksumXXHASH3.toString(),
if (checksumXXHASH64 != null)
'x-amz-checksum-xxhash64': checksumXXHASH64.toString(),
if (contentDisposition != null)
'Content-Disposition': contentDisposition.toString(),
if (contentEncoding != null)
'Content-Encoding': contentEncoding.toString(),
if (contentLanguage != null)
'Content-Language': contentLanguage.toString(),
if (contentLength != null) 'Content-Length': contentLength.toString(),
if (contentMD5 != null) 'Content-MD5': contentMD5.toString(),
if (contentType != null) 'Content-Type': contentType.toString(),
if (expectedBucketOwner != null)
'x-amz-expected-bucket-owner': expectedBucketOwner.toString(),
if (expires != null) 'Expires': expires.toString(),
if (grantFullControl != null)
'x-amz-grant-full-control': grantFullControl.toString(),
if (grantRead != null) 'x-amz-grant-read': grantRead.toString(),
if (grantReadACP != null) 'x-amz-grant-read-acp': grantReadACP.toString(),
if (grantWriteACP != null)
'x-amz-grant-write-acp': grantWriteACP.toString(),
if (ifMatch != null) 'If-Match': ifMatch.toString(),
if (ifNoneMatch != null) 'If-None-Match': ifNoneMatch.toString(),
if (metadata != null)
...metadata.map((key, value) => MapEntry('x-amz-meta-$key', value)),
if (objectLockLegalHoldStatus != null)
'x-amz-object-lock-legal-hold': objectLockLegalHoldStatus.value,
if (objectLockMode != null)
'x-amz-object-lock-mode': objectLockMode.value,
if (objectLockRetainUntilDate != null)
'x-amz-object-lock-retain-until-date':
_s.iso8601ToJson(objectLockRetainUntilDate),
if (requestPayer != null) 'x-amz-request-payer': requestPayer.value,
if (sSECustomerAlgorithm != null)
'x-amz-server-side-encryption-customer-algorithm':
sSECustomerAlgorithm.toString(),
if (sSECustomerKey != null)
'x-amz-server-side-encryption-customer-key': sSECustomerKey.toString(),
if (sSECustomerKeyMD5 != null)
'x-amz-server-side-encryption-customer-key-MD5':
sSECustomerKeyMD5.toString(),
if (sSEKMSEncryptionContext != null)
'x-amz-server-side-encryption-context':
sSEKMSEncryptionContext.toString(),
if (sSEKMSKeyId != null)
'x-amz-server-side-encryption-aws-kms-key-id': sSEKMSKeyId.toString(),
if (serverSideEncryption != null)
'x-amz-server-side-encryption': serverSideEncryption.value,
if (storageClass != null) 'x-amz-storage-class': storageClass.value,
if (tagging != null) 'x-amz-tagging': tagging.toString(),
if (websiteRedirectLocation != null)
'x-amz-website-redirect-location': websiteRedirectLocation.toString(),
if (writeOffsetBytes != null)
'x-amz-write-offset-bytes': writeOffsetBytes.toString(),
};
final $result = await _protocol.sendRaw(
method: 'PUT',
requestUri:
'/${Uri.encodeComponent(bucket)}/${key.split('/').map(Uri.encodeComponent).join('/')}?x-id=PutObject',
headers: headers,
payload: body,
exceptionFnMap: _exceptionFns,
);
final $elem = await _s.xmlFromResponse($result);
return PutObjectOutput(
bucketKeyEnabled: _s.extractHeaderBoolValue(
$result.headers, 'x-amz-server-side-encryption-bucket-key-enabled'),
checksumCRC32:
_s.extractHeaderStringValue($result.headers, 'x-amz-checksum-crc32'),
checksumCRC32C:
_s.extractHeaderStringValue($result.headers, 'x-amz-checksum-crc32c'),
checksumCRC64NVME: _s.extractHeaderStringValue(
$result.headers, 'x-amz-checksum-crc64nvme'),
checksumMD5:
_s.extractHeaderStringValue($result.headers, 'x-amz-checksum-md5'),
checksumSHA1:
_s.extractHeaderStringValue($result.headers, 'x-amz-checksum-sha1'),
checksumSHA256:
_s.extractHeaderStringValue($result.headers, 'x-amz-checksum-sha256'),
checksumSHA512:
_s.extractHeaderStringValue($result.headers, 'x-amz-checksum-sha512'),
checksumType: _s
.extractHeaderStringValue($result.headers, 'x-amz-checksum-type')
?.let(ChecksumType.fromString),
checksumXXHASH128: _s.extractHeaderStringValue(
$result.headers, 'x-amz-checksum-xxhash128'),
checksumXXHASH3: _s.extractHeaderStringValue(
$result.headers, 'x-amz-checksum-xxhash3'),
checksumXXHASH64: _s.extractHeaderStringValue(
$result.headers, 'x-amz-checksum-xxhash64'),
eTag: _s.extractHeaderStringValue($result.headers, 'ETag'),
expiration:
_s.extractHeaderStringValue($result.headers, 'x-amz-expiration'),
requestCharged: _s
.extractHeaderStringValue($result.headers, 'x-amz-request-charged')
?.let(RequestCharged.fromString),
sSECustomerAlgorithm: _s.extractHeaderStringValue(
$result.headers, 'x-amz-server-side-encryption-customer-algorithm'),
sSECustomerKeyMD5: _s.extractHeaderStringValue(
$result.headers, 'x-amz-server-side-encryption-customer-key-MD5'),
sSEKMSEncryptionContext: _s.extractHeaderStringValue(
$result.headers, 'x-amz-server-side-encryption-context'),
sSEKMSKeyId: _s.extractHeaderStringValue(
$result.headers, 'x-amz-server-side-encryption-aws-kms-key-id'),
serverSideEncryption: _s
.extractHeaderStringValue(
$result.headers, 'x-amz-server-side-encryption')
?.let(ServerSideEncryption.fromString),
size: _s.extractHeaderIntValue($result.headers, 'x-amz-object-size'),
versionId:
_s.extractHeaderStringValue($result.headers, 'x-amz-version-id'),
);
}