importDocument method

Future<ImportDocumentOutput> importDocument({
  1. required String appId,
  2. required String cardId,
  3. required String fileContentsBase64,
  4. required String fileName,
  5. required String instanceId,
  6. required DocumentScope scope,
  7. String? sessionId,
})

Uploads a file that can then be used either as a default in a FileUploadCard from Q App definition or as a file that is used inside a single Q App run. The purpose of the document is determined by a scope parameter that indicates whether it is at the app definition level or at the app session level.

May throw AccessDeniedException. May throw ContentTooLargeException. May throw InternalServerException. May throw ResourceNotFoundException. May throw ServiceQuotaExceededException. May throw ThrottlingException. May throw UnauthorizedException. May throw ValidationException.

Parameter appId : The unique identifier of the Q App the file is associated with.

Parameter cardId : The unique identifier of the card the file is associated with.

Parameter fileContentsBase64 : The base64-encoded contents of the file to upload.

Parameter fileName : The name of the file being uploaded.

Parameter instanceId : The unique identifier of the Amazon Q Business application environment instance.

Parameter scope : Whether the file is associated with a Q App definition or a specific Q App session.

Parameter sessionId : The unique identifier of the Q App session the file is associated with, if applicable.

Implementation

Future<ImportDocumentOutput> importDocument({
  required String appId,
  required String cardId,
  required String fileContentsBase64,
  required String fileName,
  required String instanceId,
  required DocumentScope scope,
  String? sessionId,
}) async {
  final headers = <String, String>{
    'instance-id': instanceId.toString(),
  };
  final $payload = <String, dynamic>{
    'appId': appId,
    'cardId': cardId,
    'fileContentsBase64': fileContentsBase64,
    'fileName': fileName,
    'scope': scope.value,
    if (sessionId != null) 'sessionId': sessionId,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri: '/apps.importDocument',
    headers: headers,
    exceptionFnMap: _exceptionFns,
  );
  return ImportDocumentOutput.fromJson(response);
}