initiateDocumentVersionUpload method

Future<InitiateDocumentVersionUploadResponse> initiateDocumentVersionUpload({
  1. required String parentFolderId,
  2. String? authenticationToken,
  3. DateTime? contentCreatedTimestamp,
  4. DateTime? contentModifiedTimestamp,
  5. String? contentType,
  6. int? documentSizeInBytes,
  7. String? id,
  8. String? name,
})

Creates a new document object and version object.

The client specifies the parent folder ID and name of the document to upload. The ID is optionally specified when creating a new version of an existing document. This is the first step to upload a document. Next, upload the document to the URL returned from the call, and then call UpdateDocumentVersion.

To cancel the document upload, call AbortDocumentVersionUpload.

May throw EntityNotExistsException. May throw EntityAlreadyExistsException. May throw StorageLimitExceededException. May throw StorageLimitWillExceedException. May throw ProhibitedStateException. May throw UnauthorizedOperationException. May throw UnauthorizedResourceAccessException. May throw FailedDependencyException. May throw ServiceUnavailableException. May throw DraftUploadOutOfSyncException. May throw ResourceAlreadyCheckedOutException.

Parameter parentFolderId : The ID of the parent folder.

Parameter authenticationToken : Amazon WorkDocs authentication token. Not required when using AWS administrator credentials to access the API.

Parameter contentCreatedTimestamp : The timestamp when the content of the document was originally created.

Parameter contentModifiedTimestamp : The timestamp when the content of the document was modified.

Parameter contentType : The content type of the document.

Parameter documentSizeInBytes : The size of the document, in bytes.

Parameter id : The ID of the document.

Parameter name : The name of the document.

Implementation

Future<InitiateDocumentVersionUploadResponse> initiateDocumentVersionUpload({
  required String parentFolderId,
  String? authenticationToken,
  DateTime? contentCreatedTimestamp,
  DateTime? contentModifiedTimestamp,
  String? contentType,
  int? documentSizeInBytes,
  String? id,
  String? name,
}) async {
  ArgumentError.checkNotNull(parentFolderId, 'parentFolderId');
  _s.validateStringLength(
    'parentFolderId',
    parentFolderId,
    1,
    128,
    isRequired: true,
  );
  _s.validateStringLength(
    'authenticationToken',
    authenticationToken,
    1,
    8199,
  );
  _s.validateStringLength(
    'contentType',
    contentType,
    1,
    128,
  );
  _s.validateStringLength(
    'id',
    id,
    1,
    128,
  );
  _s.validateStringLength(
    'name',
    name,
    1,
    255,
  );
  final headers = <String, String>{
    if (authenticationToken != null)
      'Authentication': authenticationToken.toString(),
  };
  final $payload = <String, dynamic>{
    'ParentFolderId': parentFolderId,
    if (contentCreatedTimestamp != null)
      'ContentCreatedTimestamp': unixTimestampToJson(contentCreatedTimestamp),
    if (contentModifiedTimestamp != null)
      'ContentModifiedTimestamp':
          unixTimestampToJson(contentModifiedTimestamp),
    if (contentType != null) 'ContentType': contentType,
    if (documentSizeInBytes != null)
      'DocumentSizeInBytes': documentSizeInBytes,
    if (id != null) 'Id': id,
    if (name != null) 'Name': name,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri: '/api/v1/documents',
    headers: headers,
    exceptionFnMap: _exceptionFns,
  );
  return InitiateDocumentVersionUploadResponse.fromJson(response);
}