cloudinary icon indicating copy to clipboard operation
cloudinary copied to clipboard

Cant delete image inside a folder

Open indesignlatam opened this issue 8 years ago • 9 comments

I havent been able to delete an image inside a folder using and returns not_found error, but searching for the file in cloudinary dashboard it exists.

Any comment would be helpful.

Cloudinary.delete(category.image.public_id, function(error, response){
    if(error){
     console.log(error);
    }
});

It returns

{deleted: {categories/xgtmtjsuy73cx5o5fkio: "not_found"}, partial: false, rate_limit_allowed: 500, rate_limit_reset_at: Wed Mar 09 2016 12:00:00 GMT-0500 (COT), rate_limit_remaining: 490}

indesignlatam avatar Mar 09 '16 16:03 indesignlatam

Images not in categories can be deleted without any problems.

indesignlatam avatar Mar 09 '16 16:03 indesignlatam

Strange, I'll review the delete function this weekend ^_^

Lepozepo avatar Mar 10 '16 06:03 Lepozepo

Cannot delete this as well. While find the image in cloudinary management panel by this id.

Cloudinary.delete(interest.image, function(err, res) {
   console.log("Upload Error: ", err);
   console.log("Upload Result: ", res);
});

{"deleted":{"secret/ktxkvxxukwpgelcnd6fe":"not_found"},"partial":false,"rate_limit_allowed":500,"rate_limit_reset_at":"2016-05-17T19:00:00.000Z","rate_limit_remaining":495}"

ipa1981 avatar May 17 '16 18:05 ipa1981

I have similar issue. If the public_id is short it's working. If it's something like "http://pi.lmcdn.ru/s/607/O/N/ON380EWHOS10_1_v476.jpg" (id generated by system) — it's not working. cloudinary2.txt

rvnikita avatar Jun 17 '16 18:06 rvnikita

@Lepozepo Any update on the debugging of the delete function? I am experiencing a similar issue as well. I'm uploading images into subfolders (folder name is Meteor.userId() - each user gets their own cloudinary folder).

When calling the delete function with a public_Id such as ZMnKykN2ooabFGoMd/b5gmnis3iylofgeqfwep, I get a not_found error. When browsing the media library on Cloudinary, I see that the image ZMnKykN2ooabFGoMd/b5gmnis3iylofgeqfwep does exist.

If I create an image not in a folder, I am able to delete it successfully. I wanted to use a folder structure like this to gain some organization, and to be able to check the image's owner before allowing deletion.

neufeldtech avatar Jan 23 '17 19:01 neufeldtech

@neufeldtech My problem was solved with type="fetch" parameter

full file for deletion:

import cloudinary.api
import datetime
import sys

try:
    sys.argv[1]
except:
    TIMEDELTA = 28
else:
    TIMEDELTA = int(sys.argv[1])

#CONSTANTS
MAXRESULTS = 100

next_cursor = None 
resources = cloudinary.api.resources(start_at = datetime.datetime.now() - datetime.timedelta(days=TIMEDELTA), max_results = MAXRESULTS)

while True:
    
    resources_for_deletion = [resource['public_id'].encode('utf-8') for resource in resources['resources']]

    cloudinary.api.delete_resources(resources_for_deletion, type="fetch")
    
    if "next_cursor" in resources:  #есть еще картинки
        next_cursor = resources['next_cursor']
        print next_cursor

        resources = cloudinary.api.resources(start_at = datetime.datetime.now() - datetime.timedelta(days=TIMEDELTA), max_results = MAXRESULTS, next_cursor = next_cursor)
    else: #перебрали все картинки
        print "No more images"
        break

Hope that helps.

rvnikita avatar Jan 24 '17 09:01 rvnikita

//DELETE FILES app.delete(/delete/files/:public_id, function (req,res){ resources_for_deletion = ['r0qfoindd69bmlkhfi4j'] //public_id in cloudinary Documents = 'Documents/' //name of folder cloudinary.api.delete_resources(${Documents}${resources_for_deletion},function(err,result) { console.log(result,err) }) }) I did this in Node.js. And in postman the route is this : http://localhost:3000/delete/files/r0qfoindd69bmlkhfi4j Hope that helps

fdhcastillo avatar Dec 03 '19 16:12 fdhcastillo

### Using Cloudinary SDK for JAVA to delete an image inside a folder

Map destroyResult = cloudinaryConfig.uploader().destroy("{my_folder/my_app/}" + public_id, ObjectUtils.emptyMap());
String result = destroyResult.get("result").toString();
if (result.equals("ok")) {
//Do something
}

iykeafrica avatar Apr 02 '22 23:04 iykeafrica

Uff, I've been completely disconnected from this package for a while, sorry about that guys, hopefully everyone has found an alternative by now. Definitely recommend using the official cloudinary SDK. I've only recently reactivated notifications across my older packages, hope to give some maintenance love across the board soon. https://cloudinary.com/documentation/image_upload_api_reference#destroy is the method to use for sure ^_^

Lepozepo avatar Apr 04 '22 15:04 Lepozepo