I have an cloudinary_id stored in DB and want to delete this image from Cloudinary. According documentation I call desctroy method on uploadApi with id which returns result OK. But as I see the image is still available. Dont understand it.
Tis is the code:
$cloudinary = new Cloudinary($config);
return $cloudinary->uploadApi()->destroy($file_id);
This code returns Cloudinary\Api\ApiResponse #d6b5 result => "ok"
Can somebody tell me please what is wrong with this code?
CodePudding user response:
Cloudinary uses CDN to ensure fast delivery of the media resources. That being said, when deleting a media via API, you may need to pass the optional parameter "invalidation" set to true in order to invalidate that object in their CDN. Here are their API documentation below:
https://cloudinary.com/documentation/image_upload_api_reference#destroy_method https://cloudinary.com/documentation/admin_api#delete_resources
You may use either upload API or admin API. Both achieve the same result.
Anthony
CodePudding user response:
I cannont comment yet, but following the last answer, you can use this function to solve it.
$api->deleteAssets(["image1", "image2"]);