uploadImageWithHttpInfo method
Future<Response>
uploadImageWithHttpInfo(
- String tenantId,
- MultipartFile file, {
- SizePreset? sizePreset,
- String? urlId,
Upload and resize an image
Note: This method returns the HTTP Response.
Parameters:
-
String tenantId (required):
-
MultipartFilefile (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, { SizePreset? sizePreset, String? urlId, }) async {
// 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,
);
}