startAttachmentUpload method
Provides a pre-signed Amazon S3 URL in response for uploading the file directly to S3.
For security recommendations, see Connect Customer Chat security best practices. The Amazon Connect Participant Service APIs do not use Signature Version 4 authentication.
May throw AccessDeniedException.
May throw InternalServerException.
May throw ServiceQuotaExceededException.
May throw ThrottlingException.
May throw ValidationException.
Parameter attachmentName :
A case-sensitive name of the attachment being uploaded.
Parameter attachmentSizeInBytes :
The size of the attachment in bytes.
Parameter connectionToken :
The authentication token associated with the participant's connection.
Parameter contentType :
Describes the MIME file type of the attachment. For a list of supported
file types, see Feature
specifications in the Amazon Connect Administrator Guide.
Parameter clientToken :
A unique, case-sensitive identifier that you provide to ensure the
idempotency of the request. If not provided, the Amazon Web Services SDK
populates this field. For more information about idempotency, see Making
retries safe with idempotent APIs.
Implementation
Future<StartAttachmentUploadResponse> startAttachmentUpload({
required String attachmentName,
required int attachmentSizeInBytes,
required String connectionToken,
required String contentType,
String? clientToken,
}) async {
_s.validateNumRange(
'attachmentSizeInBytes',
attachmentSizeInBytes,
1,
1152921504606846976,
isRequired: true,
);
final headers = <String, String>{
'X-Amz-Bearer': connectionToken.toString(),
};
final $payload = <String, dynamic>{
'AttachmentName': attachmentName,
'AttachmentSizeInBytes': attachmentSizeInBytes,
'ContentType': contentType,
'ClientToken': clientToken ?? _s.generateIdempotencyToken(),
};
final response = await _protocol.send(
payload: $payload,
method: 'POST',
requestUri: '/participant/start-attachment-upload',
headers: headers,
exceptionFnMap: _exceptionFns,
);
return StartAttachmentUploadResponse.fromJson(response);
}