mscdex / busboy

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

File size unavalaible #354

Open djcaesar9114 opened 6 months ago

djcaesar9114 commented 6 months ago

I saw in the README that you could access file name, file mimetype, but not file size? Why is that? I'm using multer, which is based on busboy, and I can't access file size because busboy can't give it, that's why I'm opening this issue. Thanks in advance!

mscdex commented 6 months ago

That's just the nature of multipart/* content: all fields are separated by a unique string of characters and not by their lengths. This format allows you to stream data without knowing the total size up front.

Regarding file sizes, I can't speak for downstream modules, but in busboy you can count the bytes yourself as the data streams in to find the total size and if you want to limit the max file size, you can do that too.