deleteResources method

Future<CloudinaryResponse> deleteResources({
  1. List<String>? publicIds,
  2. List<String>? urls,
  3. List<CloudinaryImage>? cloudinaryImages,
  4. String? prefix,
  5. bool? all,
  6. CloudinaryResourceType? resourceType,
  7. CloudinaryDeliveryType? deliveryType,
  8. bool? invalidate,
  9. Map<String, dynamic>? optParams,
})

Deletes a list of files of resourceType represented by it's publicIds from your specified cloudName. Alternatively you can set a prefix to delete all files where the public_id starts with the prefix or you can also set all to delete all files of resourceType By using the Delete Resources method from cloudinary Admin API. Check here https://cloudinary.com/documentation/admin_api#delete_resources

publicIds Delete all assets with the given public IDs (array of up to 100 public_ids). urls the urls list to the assets in your cloudName the publicIds will be taken from here cloudinaryImages a Cloudinary Images list to be deleted, the publicIds will be taken from here prefix Delete all assets, including derived assets, where the public ID starts with the given prefix (up to a maximum of 1000 original resources). all Delete all assets (of the relevant resource_type and type), including derived assets (up to a maximum of 1000 original resources). resourceType defaults to CloudinaryResourceType.image deliveryType defaults to CloudinaryDeliveryType.upload invalidate If true, invalidates CDN cached copies of the asset (and all its transformed versions). Default: false.

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 a Map of optional parameters as defined in https://cloudinary.com/documentation/admin_api#delete_resources

Response: Check 'deleted' map inside CloudinaryResponse to know which files were deleted

Implementation

Future<CloudinaryResponse> deleteResources(
    {List<String>? publicIds,
    List<String>? urls,
    List<CloudinaryImage>? cloudinaryImages,
    String? prefix,
    bool? all,
    CloudinaryResourceType? resourceType,
    CloudinaryDeliveryType? deliveryType,
    bool? invalidate,
    Map<String, dynamic>? optParams}) {
  if (all == null && prefix == null) {
    if (publicIds == null) {
      publicIds = [];
      if (urls != null) {
        for (var url in urls) {
          publicIds.add(CloudinaryImage(url).publicId);
        }
      } else if (cloudinaryImages != null) {
        for (var cloudinaryImage in cloudinaryImages) {
          publicIds.add(cloudinaryImage.publicId);
        }
      }
    }
  }

  return _client.deleteResources(
      publicIds: publicIds,
      prefix: prefix,
      all: all,
      resourceType: resourceType,
      deliveryType: deliveryType,
      invalidate: invalidate,
      optParams: optParams);
}