Skip to main content

How to delete an image from the client-side?

Comments

3 comments

  • Bryan Byrne

    In case it's useful to a future reader, I was personally finding it difficult to find the API endpoint that would allow me to delete using a delete_token, I found it helpful to reference this code in cloudinary jquery library, https://github.com/cloudinary/cloudinary_js/blob/6eac8e5233e6c04e772dcc0f991d28ae4d668c2a/src/jquery-file-upload.coffee#L14

    In the end it's a POST to 'https://api.cloudinary.com/v1_1/' + cloud_name + '/delete_by_token', with parameters of `public_id` and `token`.

    2
  • John Mack

    Do you have any plans or ability to bring this functionality to React?

    0
  • Stephen Doyle

    Hi John,

    The strategy here, of requesting a deletion token and using that in a subsequent API call to delete the image after it was uploaded, should work in any client-side framework, including React.

    We don't have specific support for this in the React SDK so you'd need to make an HTTP request to the API endpoint manually: https://cloudinary.com/documentation/upload_images#deleting_client_side_uploaded_assets

    Generally speaking, we don't intend to add support in the client-side SDKs for destructive actions because almost all other cases would require the API secret to be in the application code, which is not recommended for security reasons

    If you'd like assistance with making the API calls from React, please open a support request with information about your current workflow and we'd be happy to advise

    Thanks,

    Stephen

    0

Please sign in to leave a comment.