richardgirges / express-fileupload

Simple express file upload middleware that wraps around busboy
MIT License
1.52k stars 261 forks source link

Data event fired after limit event when the limit value is smaller than the readable stream default value of highWaterMark(6 KiB) #321

Closed gjf7 closed 1 year ago

gjf7 commented 2 years ago

As the example below, the file size limit is smaller than the readable stream default value of highWaterMark, which could lead to a bug that data can not be written into buffer or temp file. Because complete = true in the clean up function stopped the data.

app.use(cors())
app.use(fileupload({
  useTempFiles: true,
  limits: { fileSize: 5 * 1024 },
  abortOnLimit: true,
  debug: true
}))

app.post("/upload", (req, res) => {
  console.log("upload main function fired", req.files)
})

app.listen(8000, () => {
  console.log("app online")
})

Snipaste_2022-06-26_18-40-38