mscdex / busboy

A streaming parser for HTML form data for node.js
MIT License
2.84k stars 213 forks source link

How can we know the size of the file uploded in busboy? I want to know the exact size of the file #320

Closed Maleeha456 closed 1 year ago

mscdex commented 1 year ago

That's up to you to keep track of. busboy just provides the file streams.

gazebosx3 commented 1 year ago

It looks like lib/types/multipart.js calculates the file size already to check fileSizeLimit. Would you guys consider implementing/accepting a PR for that size to be emitted as a property on the FileInfo that already gets returned for bb.on('file'...)?

charmander commented 1 year ago

@gazebosx3 That’s not possible in general. fileSizeLimit is checked as the stream for the file is read, i.e. after the file event is emitted.

mscdex commented 1 year ago

@gazebosx3 As @charmander said, that's not possible. You will need to count the bytes yourself as the file streams in if you need the total size when the stream ends.