startContentUpload method

Future<StartContentUploadResponse> startContentUpload({
  1. required String contentType,
  2. required String knowledgeBaseId,
  3. int? presignedUrlTimeToLive,
})

Get a URL to upload content to a knowledge base. To upload content, first make a PUT request to the returned URL with your file, making sure to include the required headers. Then use CreateContent to finalize the content creation process or UpdateContent to modify an existing resource. You can only upload content to a knowledge base of type CUSTOM.

May throw AccessDeniedException. May throw ResourceNotFoundException. May throw UnauthorizedException. May throw ValidationException.

Parameter contentType : The type of content to upload.

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

Parameter presignedUrlTimeToLive : The expected expiration time of the generated presigned URL, specified in minutes.

Implementation

Future<StartContentUploadResponse> startContentUpload({
  required String contentType,
  required String knowledgeBaseId,
  int? presignedUrlTimeToLive,
}) async {
  _s.validateNumRange(
    'presignedUrlTimeToLive',
    presignedUrlTimeToLive,
    1,
    60,
  );
  final $payload = <String, dynamic>{
    'contentType': contentType,
    if (presignedUrlTimeToLive != null)
      'presignedUrlTimeToLive': presignedUrlTimeToLive,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri:
        '/knowledgeBases/${Uri.encodeComponent(knowledgeBaseId)}/upload',
    exceptionFnMap: _exceptionFns,
  );
  return StartContentUploadResponse.fromJson(response);
}