documentFilesUploadSingleFileWithHttpInfo method

Future<Response> documentFilesUploadSingleFileWithHttpInfo(
  1. String tenantId,
  2. String region,
  3. MultipartFile file,
  4. String documentName,
  5. int assetId,
  6. int modelId, {
  7. String externalId,
})

Uploads a document file related to a specific model

Summary:Uploads a document file related to a specific model.
The document will be associated with the asset and model provided in the Form data parameters.
Return Type: FileUploadResult

Note: This method returns the HTTP Response.

Parameters:

  • String tenantId (required): The unique Tenant ID (UUID or Identifier string)

  • String region (required): The data center region the data resides in

  • MultipartFile file (required): An arbitrary document which will get associated to the model or its parts.

  • String documentName (required): The name of the Document

  • int assetId (required): Asset which should contain the document

  • int modelId (required): Asset model which should contain the document

  • String externalId: External identity of the document. This will be used for versioning.

Implementation

Future<Response> documentFilesUploadSingleFileWithHttpInfo(String tenantId, String region, MultipartFile file, String documentName, int assetId, int modelId, { String externalId, }) async {
  // Verify required params are set.
  if (tenantId == null) {
   throw ApiException(HttpStatus.badRequest, 'Missing required param: tenantId');
  }
  if (region == null) {
   throw ApiException(HttpStatus.badRequest, 'Missing required param: region');
  }
  if (file == null) {
   throw ApiException(HttpStatus.badRequest, 'Missing required param: file');
  }
  if (documentName == null) {
   throw ApiException(HttpStatus.badRequest, 'Missing required param: documentName');
  }
  if (assetId == null) {
   throw ApiException(HttpStatus.badRequest, 'Missing required param: assetId');
  }
  if (modelId == null) {
   throw ApiException(HttpStatus.badRequest, 'Missing required param: modelId');
  }

  // ignore: prefer_const_declarations
  final path = r'/{region}/aim/2.0/{tenantId}/documentfiles/upload'
    .replaceAll('{tenantId}', tenantId)
    .replaceAll('{region}', region);

  // ignore: prefer_final_locals
  Object postBody;

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

  const authNames = <String>['oauth2'];
  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 (documentName != null) {
    hasFields = true;
    mp.fields[r'documentName'] = parameterToString(documentName);
  }
  if (assetId != null) {
    hasFields = true;
    mp.fields[r'assetId'] = parameterToString(assetId);
  }
  if (modelId != null) {
    hasFields = true;
    mp.fields[r'modelId'] = parameterToString(modelId);
  }
  if (externalId != null) {
    hasFields = true;
    mp.fields[r'externalId'] = parameterToString(externalId);
  }
  if (hasFields) {
    postBody = mp;
  }

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