uploadPluginWithHttpInfo method

Future<Response> uploadPluginWithHttpInfo(
  1. MultipartFile plugin, {
  2. String? force,
})

Upload plugin

Upload a plugin that is contained within a compressed .tar.gz file. Plugins and plugin uploads must be enabled in the server's config settings. ##### Permissions Must have manage_system permission. Minimum server version: 4.4

Note: This method returns the HTTP Response.

Parameters:

  • MultipartFile plugin (required): The plugin image to be uploaded

  • String force: Set to 'true' to overwrite a previously installed plugin with the same ID, if any

Implementation

Future<Response> uploadPluginWithHttpInfo(
  MultipartFile plugin, {
  String? force,
}) async {
  // ignore: prefer_const_declarations
  final path = r'/plugins';

  // ignore: prefer_final_locals
  Object? postBody;

  final queryParams = <MmQueryParam>[];
  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 (plugin != null) {
    hasFields = true;
    mp.fields[r'plugin'] = plugin.field;
    mp.files.add(plugin);
  }
  if (force != null) {
    hasFields = true;
    mp.fields[r'force'] = parameterToString(force);
  }
  if (hasFields) {
    postBody = mp;
  }

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