👋 I know folders are not a thing but
👋 I know folders are not a thing, but still, what would be the best way to delete by prefix? Use case: we will use folders to store "per customer" data, and ideally, we'd like to delete all files from a prefix quickly.
3 Replies
Side question: if we have to delete files one by one, which way is "faster": 1. a worker bound to the bucket using rm or 2. using the s3 api to http delete? Thanks!
ListObjectsV2 can get all objects by prefix, on the API, then you can issue DeleteObjects to remove up to a 1000 objects at once
Whichever AWS SDK you're using should have both
Just to answer your side question (even though you should do what Karew suggests): Both 1. & 2. end up in the exact same code path on R2; what's going to make one faster than the other is the network.
If you run both 1. & 2. close to your bucket's location, the Worker might be faster (assuming one Worker invocation sends out multiple individual DeleteObject calls)