Destroy an image using angular
Hi,
I am looking for a way to destroy an image using angular but haven't found any documentation about it. Should I use ng2-file-upload or do a direct api call and generate a signature first?
As a temporary solution I'm doing this in my api with the CoundinaryDotNet library but I don't think it's the optimal way to go, since I want to destroy an image as soon as a user uploads a new one (for profile pictures, banners, etc).
King regards,
Nathan
-
Hi Nathan,
Deletion requests are all based on signed API and therefore are only available via the server-side SDKs (e.g. Java, Rails, NodeJS, etc.). Therefore you cannot use Angular to do the deletion.
You can certainly use Angular to do signed uploads. This is done on the server-side so the signature generation will be done there. This is because the signature is based on your account's api_secret which must be excluded from your client-side code. Please refer to https://support.cloudinary.com/hc/en-us/community/posts/207777389-Signed-Upload-on-Angular for the explanation.
Here is a step-by-step implementation of doing upload using Angular: https://cloudinary.com/blog/file_upload_with_angular_or_angularjs_to_cloudinary
If you are uploading subsequent images with the same public_id, then you can set invalidate=true and overwrite=true. This way the subsequent uploads will overwrite the existing one.
On the other hand, if you are uploading images that have different public_id, then you can use our server-side SDK to do the deletion: https://cloudinary.com/documentation/admin_api#delete_resources
I hope this helps and let us know if you need further assistance,
Regards,
Mo
Cloudinary Dev Support
1
Post is closed for comments.
Comments
1 comment