Add a stop or abort method
See original GitHub issueRight now the only way I have found to stop a file form uploading is to call busboy._parser.parser._ignore()
. It would be great if you exposed some sort of abort method.
Use case: you want to do some validation on the image, but as soon as the image is not valid, stop uploading the image and return the error to the client. If you’re uploading a 1 gig image and you can figure out 1/4 of the way through parsing it that it’s the wrong width then it’s much better to stop then as opposed to making the user wait until finish
event is called.
Example pseudoish code of I’d like to do:
if (self.req.method === 'POST') {
var busboy = this.busboy = new Busboy({
headers: self.req.headers
});
busboy.on('file', function(fieldname, file, filename, encoding, mimetype) {
file.on('data', function(data) {
if(IMAGE IS THE WRONG WIDTH) {
busboy.abort();
}
if(IMAGE IS THE WRONG DPI) {
busboy.abort();
}
if(IMAGE IS THE WRONG SOMETHING ELSE) {
busboy.abort();
}
});
});
busboy.on('aborted', function() {
// DO SOMETHING HERE ... maybe return error to the client
});
}
Issue Analytics
- State:
- Created 8 years ago
- Reactions:4
- Comments:8 (5 by maintainers)
Top Results From Across the Web
Steps to Stop or Abort - Informatica Documentation
Click Tasks > Stop or Tasks > Abort. The Workflow Monitor displays the status of the stop or abort command in the Output...
Read more >How to abort a Task like aborting a Thread ... - Stack Overflow
The Thread. Abort() method is (severely) deprecated. Both Threads and Tasks should cooperate when being stopped, otherwise you run the risk of leaving...
Read more >XMLHttpRequest.abort() - Web APIs - MDN Web Docs
abort () method aborts the request if it has already been sent. When a request is aborted, its readyState is changed to XMLHttpRequest.UNSENT...
Read more >ABORT Statement - SAS Help Center
The ABORT statement causes SAS to stop processing the current DATA step. What happens next depends on the following information: the method ......
Read more >Fetch: Abort - The Modern JavaScript Tutorial
It has a single method abort() , · And a single property signal that allows to set event listeners on it.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@mscdex So this is what I have:
Also I was wrong, 200 isn’t returned. It’s just sitting in pending (never returning). Is there a nice way to end the pipe with the exception?
.end()
?Ok so dur… it was just my
status
bit I had incorrect:Thanks
A better solution though to avoid processing unnecessary data might be to do something like: