Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
parser.on("file", (fieldname, stream, filename, encoding, mimetype) => {
if (exitError) {
this.wasteStream(stream);
return;
}
currentStream = stream;
stream.on("end", () => {
currentStream = undefined;
});
// create buffer stream
const capacitor = new WriteStream();
capacitor.on("error", () => {
stream.unpipe();
stream.resume();
});
stream.on("error", error => {
stream.unpipe();
capacitor.destroy(error);
});
stream.on("limit", () => {
stream.unpipe();
capacitor.destroy(new Error(`file ${filename} exceeds the ${this.props.maxFileSize} byte size limit`)); // TODO: normalize error
});