uploadImageWithHttpInfo method

Future<Response> uploadImageWithHttpInfo(
  1. String tenantId,
  2. MultipartFile file, [
  3. UploadImageOptions? options
])

Upload and resize an image

Note: This method returns the HTTP Response.

Parameters:

  • String tenantId (required):

  • MultipartFile file (required):

  • SizePreset sizePreset: Size preset: "Default" (1000x1000px) or "CrossPlatform" (creates sizes for popular devices)

  • String urlId: Page id that upload is happening from, to configure

Implementation

Future<Response> uploadImageWithHttpInfo(String tenantId, MultipartFile file, [ UploadImageOptions? options ]) async {
  final sizePreset = options?.sizePreset;
  final urlId = options?.urlId;
  // ignore: prefer_const_declarations
  final path = r'/upload-image/{tenantId}'
    .replaceAll('{tenantId}', tenantId);

  // ignore: prefer_final_locals
  Object? postBody;

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

  if (sizePreset != null) {
    queryParams.addAll(_queryParams('', 'sizePreset', sizePreset));
  }
  if (urlId != null) {
    queryParams.addAll(_queryParams('', 'urlId', urlId));
  }

  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 (hasFields) {
    postBody = mp;
  }

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