how to access photo public id including a folder name?

rwahdan
rwahdan Member Posts: 51

I am trying to delete photos from my API using the photo public id but with one issue, I have the photos inside a folder so the photo public id is something like this:

foldername/photoname_dkjshksjhdk

and if i try to delete that photo it will bring error file not found as it will treat it as a path rather than public id.

http://localhost:5180/api/familydocuments/delete-photo/foldername/photoname_dkjshksjhdk

Tagged:

Answers

  • Cloudinary Team
    Cloudinary Team Administrator, Cloudinary Staff Posts: 170 admin

    Hi there,

    Thanks for reaching out.

    It is not a problem to delete assets inside of folders. You just pass the full public_id to the destroy method call. So for example, if you had a folder named 'cats' and you wanted to delete an asset, 'noDogsAllowed.jpg' inside of that folder, you would pass "cats/noDogsAllowed"
    You can refer to our documentation for additional information, including code examples:
    https://cloudinary.com/documentation/image_upload_api_reference#destroy

    I hope this helps. If you have any questions, just let us know.

    Kind regards,

    Tia

    Helpful Links For You
    💬 Share questions, connect with other users in our Cloudinary Community forums and Discord server!
    🧑‍🎓 Join our Cloudinary Academy for free courses, workshops and other educational resources.
    📄 Read our documentation for in-depth details on Cloudinary product features and capabilities
    📰 Check out the Cloudinary blog for the latest company news and insights