deleteResource method

Future<CloudinaryResponse> deleteResource({
  1. String? publicId,
  2. String? url,
  3. CloudinaryImage? cloudinaryImage,
  4. CloudinaryResourceType? resourceType,
  5. bool? invalidate,
  6. Map<String, dynamic>? optParams,
})

Deletes a file of resourceType with publicId from your specified cloudName By using the Destroy method of cloudinary api. Check here https://cloudinary.com/documentation/image_upload_api_reference#destroy_method

publicId the asset id in your cloudName, if not provided then url would be used. Note: The public ID value for images and videos should not include a file extension. Include the file extension for raw files only. url the url to the asset in your cloudName, the publicId will be taken from here cloudinaryImage a Cloudinary Image to be deleted, the publicId will be taken from here resourceType defaults to CloudinaryResourceType.image invalidate If true, invalidates CDN cached copies of the asset (and all its transformed versions). Default: false. optParams a Map of optional parameters as defined in https://cloudinary.com/documentation/image_upload_api_reference#destroy_method

Response: Check response.isResultOk to know if the file was successfully deleted.

Implementation

Future<CloudinaryResponse> deleteResource(
    {String? publicId,
    String? url,
    CloudinaryImage? cloudinaryImage,
    CloudinaryResourceType? resourceType,
    bool? invalidate,
    Map<String, dynamic>? optParams}) {
  publicId ??= (cloudinaryImage ?? CloudinaryImage(url ?? '')).publicId;
  return _client.destroy(publicId,
      resourceType: resourceType,
      invalidate: invalidate,
      optParams: optParams);
}