Closed DvDream closed 1 year ago
There are a few issues I see with the code you've posted:
if (req.complete) {
return;
}
is not correct, you should always consume file
whether you're interested in it or not if you have a 'file'
event handler. At the minimum that means using something like file.resume();
before your return
.
Using the filename as-is like that puts you at risk for security issues if the filename is maliciously crafted (e.g. contains a relative path to escape your upload directory).
If the request is still pending after you've verified a response has been sent, then perhaps something (in Express or elsewhere) is still waiting for the request to be completely drained. If that's the case, you'll need to add something like req.resume()
after you req.unpipe(busboy)
to ensure any remaining data is drained out.
Hi, I am trying to load a zip file through busboy-connect. I am using expressjs for the server side. The flow would be to load the zip file, check if the content of the zip (which is a folder) already exists in the file system and if not, unzip it e save it in the desired path.
In the case that the file does not exist everything is fine, the problem I am having is with my custom middleware that handle the error for an already existing file. The problem is that in this case the request remain pending and it is not sent back to the client.
I also tried to use my custom middleware outside the busboy "file" event and in that case everything is fine (i.e. the error is thrown ) the response is sent back to the client.
this is my middleware (which is put after every other app.use() ones.
The problem is that I would need to know the name of the file server side but I can check it only inside the "file" event