uploadcare/pyuploadcare

delete filegroup

M00NSH0T opened this issue · 3 comments

I might be missing something, but it appears there's no way to delete filegroups. I can delete all the individual files within a group (though not easily because if I reference I filegroup, pulling the UUIDs out for each image is not trivial), but once I do that I can't figure out how to delete the group itself. I know they're immutable, but can't they be deleted?

Also, it'd be nice to be able to delete all the files within the group, as well as the group itself in one function call.

Currently, I'm struggling to even delete the files withing a single filegroup. For security purposes, I'm trying to essentially delete the files for each of my Shopify store's orders as soon as I'm done processing it, Each order creates a single filegroup of images I use, so I really want to just delete all the files in a filegroup each time a particular function finishes its work. But sending the full cdn_urls for the files within the group to the delete_files method, as shown below, doesn't end up deleting anything. It doesn't throw any errors, but these files are still there after running it. Maybe the delete_files method should be updated to accept a list of cdn_urls instead of just lists of uuids?

file_groups = uploadcare.list_file_groups(limit=10)
for file_group in tqdm(file_groups):
    delete_these=file_group.file_cdn_urls
    uploadcare.delete_files(delete_these)

As far as I can tell, I'd need to dig into the info for each file to pull the UUID out, then delete them one by one, though I have yet to get that to actually work.

yes, file groups are immutable and are undeletable.
this is by design.

I agree, that it would be convenient to use URLs as well as more easy way to delete all files in a group.
I would recommend the following change:

file_groups = uploadcare.list_file_groups(limit=10)
for file_group in tqdm(file_groups):
    uploadcare.delete_files([file.uuid for file in file_group])

you can optimize this by getting sending list of 100 to delete endpoint.
you'll need this anyway, if you have groups larger than 100 files.

super helpful thanks!

I've submitted few enhreqs. Closing this.
Thanks for the feedback!