uploadChunkedBlockWithHttpInfo method

Future<Response> uploadChunkedBlockWithHttpInfo(
  1. String sessionId,
  2. String blockHash,
  3. MultipartFile block, {
  4. int? blockIndex,
})

Upload one block for an open chunked-upload session.

Note: This method returns the HTTP Response.

Parameters:

  • String sessionId (required):

  • String blockHash (required):

  • MultipartFile block (required):

  • int blockIndex:

Implementation

Future<Response> uploadChunkedBlockWithHttpInfo(String sessionId, String blockHash, MultipartFile block, { int? blockIndex, }) async {
  // ignore: prefer_const_declarations
  final path = r'/v1/files/upload/chunked/blocks';

  // ignore: prefer_final_locals
  Object? postBody;

  final queryParams = <QueryParam>[];
  final headerParams = <String, String>{};
  final formParams = <String, String>{};

  const contentTypes = <String>['multipart/form-data'];

  bool hasFields = false;
  final mp = MultipartRequest('POST', Uri.parse(path));
  if (sessionId != null) {
    hasFields = true;
    mp.fields[r'sessionId'] = parameterToString(sessionId);
  }
  if (blockHash != null) {
    hasFields = true;
    mp.fields[r'blockHash'] = parameterToString(blockHash);
  }
  if (blockIndex != null) {
    hasFields = true;
    mp.fields[r'blockIndex'] = parameterToString(blockIndex);
  }
  if (block != null) {
    hasFields = true;
    mp.fields[r'block'] = block.field;
    mp.files.add(block);
  }
  if (hasFields) {
    postBody = mp;
  }

  return apiClient.invokeAPI(
    path,
    'POST',
    queryParams,
    postBody,
    headerParams,
    formParams,
    contentTypes.isEmpty ? null : contentTypes.first,
  );
}