startAttachmentUpload method

Future<StartAttachmentUploadResponse> startAttachmentUpload({
  1. required String attachmentName,
  2. required int attachmentSizeInBytes,
  3. required String connectionToken,
  4. required String contentType,
  5. String? clientToken,
})

Provides a pre-signed Amazon S3 URL in response for uploading the file directly to S3.

May throw AccessDeniedException. May throw InternalServerException. May throw ThrottlingException. May throw ValidationException. May throw ServiceQuotaExceededException.

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 to support idempotency of request.

Implementation

Future<StartAttachmentUploadResponse> startAttachmentUpload({
  required String attachmentName,
  required int attachmentSizeInBytes,
  required String connectionToken,
  required String contentType,
  String? clientToken,
}) async {
  ArgumentError.checkNotNull(attachmentName, 'attachmentName');
  _s.validateStringLength(
    'attachmentName',
    attachmentName,
    1,
    256,
    isRequired: true,
  );
  ArgumentError.checkNotNull(attachmentSizeInBytes, 'attachmentSizeInBytes');
  _s.validateNumRange(
    'attachmentSizeInBytes',
    attachmentSizeInBytes,
    1,
    1152921504606846976,
    isRequired: true,
  );
  ArgumentError.checkNotNull(connectionToken, 'connectionToken');
  _s.validateStringLength(
    'connectionToken',
    connectionToken,
    1,
    1000,
    isRequired: true,
  );
  ArgumentError.checkNotNull(contentType, 'contentType');
  _s.validateStringLength(
    'contentType',
    contentType,
    1,
    255,
    isRequired: true,
  );
  _s.validateStringLength(
    'clientToken',
    clientToken,
    1,
    500,
  );
  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);
}