How to delete all of images in a group

I created my content with a multi upload widget.When I delete my content ,I want to delete the group of images associated with content. I have successfully delete indivudual images when I use single upload widget but I can’t delete gruop images.Is there a short way to delete group and all images in it?

 $.ajax({
     url: "https://api.uploadcare.com/groups/" + "b95820d9-bf50-4ca4-8a8e-ce90cf782bf1~2/nth/0/",
     type: "DELETE",
     headers: {
         "Accept": "application/vnd.uploadcare-v0.5+json",
         "Authorization": "Uploadcare.Simple xxxxxxxxx:xxxxxxxxxxxxx"
     },
     success: function(result) {

     },
     error: function(result) {

     }
 });

@kayalif1 Unfortunately, there’s no way to delete an entire group via a single request. You have to list the files from the group and then remove them one by one or via the batch remove request.

1 Like

Hello guys!
Probably there was a change in your API? Is it possible now to delete all files within a single request by groupID?

In my case multi file uploader is a part of the form. And when a user decides to cancel the form without submitting it I need to delete the files he/she has uploaded. What is the best way to do it on the frontend side?

Hi @Eugene_Steblin,

We haven’t implemented such a method yet.

Our API allows you to store all files in a group with a single request, though, and you might want to adjust your workflow to leverage this method. You could disable auto file storing in your project settings, and if a user submits the form, your app makes a request to store all files in the group. Otherwise, the uploaded files will be deleted automatically in 24 hours.

Let me know what you think.

Hi @Alex ,

We use your frontend widget to upload files and then we just send the link to the backend to store it. If we change this flow we’ll need to update every single place on the backend where we work with your service to make an additional API requests to actually save files. Did I get it right? If yes, then it seems to be quite a big effort.

Yes, it would require changing the backend logic. Currently, you make multiple requests to delete the files that have been uploaded, but the form hasn’t been submitted. If you changed the workflow, you’d need to make a single request to store a filegroup if the form has been submitted.

Either way, deleting a filegroup with a single request seems to be a good idea for a feature request, so I’m moving this topic to #feature-requests. We’ll do some research to see if we can implement this in the next versions of the REST API.