Remove all files from s3 bucket using nodejs knox?

2.8k views Asked by At

I am using knox npm module to upload files to a bucket on S3. It works great. What I am not sure how to do is how to remove all the files from a bucket in one call instead of deleting one file at the time?

any idea would help...

2

There are 2 answers

0
Steffen Opel On

This has not been possible in the past, however, Amazon has finally introduced Amazon S3 - Multi-Object Delete in December 2011:

Amazon S3's new Multi-Object Delete gives you the ability to delete up to 1000 objects from an S3 bucket with a single request.

Obviously client libraries like knox must add dedicated support for this API now in turn, and a respective issue does indeed exist already in knox' issue tracker (still pending as of today), see Multi-Object Delete.

Accordingly you should monitor this issue and/or participate in the implementation :)


3
chilts On

My AwsSum library can already do multi object delete. The operation in the library is called 'DeleteMultipleObjects':

You can install AwsSum via npm doing:

$ npm install awssum

There is an example here:

Hope it goes well and give me a shout if you need any assistance. :)