createMessageTemplateAttachment method

Future<CreateMessageTemplateAttachmentResponse> createMessageTemplateAttachment({
  1. required String body,
  2. required ContentDisposition contentDisposition,
  3. required String knowledgeBaseId,
  4. required String messageTemplateId,
  5. required String name,
  6. String? clientToken,
})

Uploads an attachment file to the specified Amazon Q in Connect message template. The name of the message template attachment has to be unique for each message template referenced by the $LATEST qualifier. The body of the attachment file should be encoded using base64 encoding. After the file is uploaded, you can use the pre-signed Amazon S3 URL returned in response to download the uploaded file.

May throw AccessDeniedException. May throw ConflictException. May throw ResourceNotFoundException. May throw ServiceQuotaExceededException. May throw ThrottlingException. May throw UnauthorizedException. May throw ValidationException.

Parameter body : The body of the attachment file being uploaded. It should be encoded using base64 encoding.

Parameter contentDisposition : The presentation information for the attachment file.

Parameter knowledgeBaseId : The identifier of the knowledge base. Can be either the ID or the ARN. URLs cannot contain the ARN.

Parameter messageTemplateId : The identifier of the message template. Can be either the ID or the ARN. It cannot contain any qualifier.

Parameter name : The name of the attachment file being uploaded. The name should include the file extension.

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<CreateMessageTemplateAttachmentResponse>
    createMessageTemplateAttachment({
  required String body,
  required ContentDisposition contentDisposition,
  required String knowledgeBaseId,
  required String messageTemplateId,
  required String name,
  String? clientToken,
}) async {
  final $payload = <String, dynamic>{
    'body': body,
    'contentDisposition': contentDisposition.value,
    'name': name,
    if (clientToken != null) 'clientToken': clientToken,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri:
        '/knowledgeBases/${Uri.encodeComponent(knowledgeBaseId)}/messageTemplates/${Uri.encodeComponent(messageTemplateId)}/attachments',
    exceptionFnMap: _exceptionFns,
  );
  return CreateMessageTemplateAttachmentResponse.fromJson(response);
}