Cannot delete resources with spaces in public_id
Hi,
I am trying to delete an image with public Id : ..../courses/I%20am%20testing/images/course_preview_img.jpg
Why do I get not found:
{...
"result": {
"partial": false,
"deleted": {
"courses/I%20am%20testing/videos/Cows": "not_found",
"courses/I%20am%20testing/images/course_preview_img": "not_found",
"courses/I%20am%20testing/images/coverPhoto": "not_found",
"courses/I%20am%20testing/images/profilePhoto": "not_found"
},
"rate_limit_allowed": 500,
"rate_limit_remaining": 497,
"deleted_counts": {
"courses/I%20am%20testing/videos/Cows": {
"derived": 0,
"original": 0
},
"courses/I%20am%20testing/images/course_preview_img": {
"derived": 0,
"original": 0
},
"courses/I%20am%20testing/images/coverPhoto": {
"derived": 0,
"original": 0
},
"courses/I%20am%20testing/images/profilePhoto": {
"derived": 0,
"original": 0
}
},
"rate_limit_reset_at": "2022-02-20T22:00:00.000Z"
}
}
}
}
But when the resource id has no space it is found:
{...
"result": {
"partial": false,
"deleted": {
"courses/Booga/videos/Sound": "not_found",
"courses/Booga/images/course_preview_img": "deleted",
"courses/Booga/images/profilePhoto": "deleted",
"courses/Booga/images/coverPhoto": "deleted"
},
"rate_limit_allowed": 500,
"rate_limit_remaining": 495,
"deleted_counts": {
"courses/Booga/videos/Sound": {
"derived": 0,
"original": 0
},
"courses/Booga/images/course_preview_img": {
"derived": 0,
"original": 1
},
"courses/Booga/images/profilePhoto": {
"derived": 0,
"original": 1
},
"courses/Booga/images/coverPhoto": {
"derived": 0,
"original": 1
}
},
"rate_limit_reset_at": "2022-02-20T22:00:00.000Z"
}
}
}
Using
cloudinary.v2.api.delete_resources
-
Hi Andres,
When using the Admin API delete_resources method, the public_id must not be encoded (i.e., for your case, use space character instead of %20). For example:
cloudinary.api.delete_resources(
["courses/I am testing/videos/Cows",
"courses/I am testing/images/course_preview_img",
"courses/I am testing/images/coverPhoto",
"courses/I am testing/images/profilePhoto"
],
{ type: 'upload' },
function(error, result) {console.log(result, error); });Hope this helps. Thanks.
Post is closed for comments.
Comments
1 comment