uploadFileWithHttpInfo method

Future<Response> uploadFileWithHttpInfo(
  1. MultipartFile file, {
  2. String? folderId,
  3. String? workspaceId,
  4. String? organizationId,
  5. String? accountId,
})

Upload a file via multipart form.

Multipart upload. Form field file carries the binary; auxiliary form fields scope the upload (folderId, workspaceId, organizationId, accountId). Max body size is currently 100 MB.

Note: This method returns the HTTP Response.

Parameters:

  • MultipartFile file (required): File bytes (multipart form field name file).

  • String folderId:

  • String workspaceId:

  • String organizationId:

  • String accountId:

Implementation

Future<Response> uploadFileWithHttpInfo(MultipartFile file, { String? folderId, String? workspaceId, String? organizationId, String? accountId, }) async {
  // ignore: prefer_const_declarations
  final path = r'/v1/files/upload';

  // 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 (file != null) {
    hasFields = true;
    mp.fields[r'file'] = file.field;
    mp.files.add(file);
  }
  if (folderId != null) {
    hasFields = true;
    mp.fields[r'folderId'] = parameterToString(folderId);
  }
  if (workspaceId != null) {
    hasFields = true;
    mp.fields[r'workspaceId'] = parameterToString(workspaceId);
  }
  if (organizationId != null) {
    hasFields = true;
    mp.fields[r'organizationId'] = parameterToString(organizationId);
  }
  if (accountId != null) {
    hasFields = true;
    mp.fields[r'accountId'] = parameterToString(accountId);
  }
  if (hasFields) {
    postBody = mp;
  }

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