I am using https://www.npmjs.com/package/s3 package to download folder from s3 but I am not able to find any method to cancel the download or interrupt the download process.
So how can I interrupt the ongoing download or stop the download process? Any suggestions for packages offering this feature?
Folder size is upto 10GB and folder contains 1000s of file so it is creating multiple requests for same folder.
I modified the code of the s3
module to allow cancellation.
Here's the PR, but in the meantime you can use my fork for testing:
const downloader = client.downloadFile(params);
downloader.on('error', function(err) {
console.error('unable to download:', err.stack);
});
downloader.on('cancelled', function() {
console.log('Download was cancelled:');
});
downloader.on('progress', function() {
console.log('progress', downloader.progressAmount, downloader.progressTotal);
});
downloader.on('end', function() {
console.log('done downloading');
});
setTimeout(() => {
downloader.emit('cancel');
}, 2000);
What I added is a way to call request.abort()
on the s3.getObject
request.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With