uploadData method

Future<MmFileInfo?> uploadData(
  1. String uploadId
)

Perform a file upload

Starts or resumes a file upload. To resume an existing (incomplete) upload, data should be sent starting from the offset specified in the upload session object. The request body can be in one of two formats: - Binary file content streamed in request's body - multipart/form-data ##### Permissions Must be logged in as the user who created the upload session.

Parameters:

  • String uploadId (required): The ID of the upload session the data belongs to.

Implementation

Future<MmFileInfo?> uploadData(
  String uploadId,
) async {
  final response = await uploadDataWithHttpInfo(
    uploadId,
  );
  if (response.statusCode >= HttpStatus.badRequest) {
    throw MmApiException(response.statusCode, await _decodeBodyBytes(response));
  }
  // When a remote server returns no body with a status of 204, we shall not decode it.
  // At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
  // FormatException when trying to decode an empty string.
  if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
    return await apiClient.deserializeAsync(
      await _decodeBodyBytes(response),
      'MmFileInfo',
    ) as MmFileInfo;
  }
  return null;
}