createPresignedUrl method

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

Creates a presigned URL for an S3 POST operation to upload a file. You can use this URL to set a default file for a FileUploadCard in a Q App definition or to provide a file for a single Q App run. The scope parameter determines how the file will be used, either at the app definition level or the app session level.

May throw AccessDeniedException. May throw InternalServerException. 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 fileContentsSha256 : The Base64-encoded SHA-256 digest of the contents of the file to be uploaded.

Parameter fileName : The name of the file to be 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<CreatePresignedUrlOutput> createPresignedUrl({
  required String appId,
  required String cardId,
  required String fileContentsSha256,
  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,
    'fileContentsSha256': fileContentsSha256,
    'fileName': fileName,
    'scope': scope.value,
    if (sessionId != null) 'sessionId': sessionId,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri: '/apps.createPresignedUrl',
    headers: headers,
    exceptionFnMap: _exceptionFns,
  );
  return CreatePresignedUrlOutput.fromJson(response);
}