Skip to content

Image reset does not work #795

Answered by NikRoe
gwittm asked this question in Web
Dec 11, 2023 · 3 comments · 1 reply
Discussion options

You must be logged in to vote

Hi Gabi,

when deleting an image from cloudinary, you can use the destroy method Cloudinary provides.

This method accepts the public_id of the respective image as an argument. Since this is an information that is currently not stored in your application, we need to make some adjustments.

The code in your API Route (/api/upload/index.js) could look similar to this:

if (request.method === "DELETE") {
    const public_id = request.query.id;

    await cloudinary.v2.uploader.destroy(public_id);

    response.status(200).json({ message: "Image removed from Cloud" });
  }

You should make sure that this if statement will actually be reached. Right now there is a check in that route that only acce…

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by NikRoe
Comment options

You must be logged in to vote
1 reply
@NikRoe
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Web
Labels
None yet
2 participants