Lepozepo / cloudinary

MIT License
94 stars 42 forks source link

Cant delete image inside a folder #76

Open indesignlatam opened 8 years ago

indesignlatam commented 8 years ago

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 commented 8 years ago

Images not in categories can be deleted without any problems.

Lepozepo commented 8 years ago

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

ipa1981 commented 8 years ago

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}"

rvnikita commented 8 years ago

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

neufeldtech commented 7 years ago

@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.

rvnikita commented 7 years ago

@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.

fdhcastillo commented 4 years ago

//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

iykeafrica commented 2 years ago

### 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
}
Lepozepo commented 2 years ago

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 ^_^