busboy
busboy copied to clipboard
Typings for field name
Hi!
@types/busboy has this typing:
file: (name: string, stream: Readable, info: FileInfo) => void;
But if field name is not set, then it comes as undefined, not as string in this callback
HTTP example:
> POST /api/files/upload HTTP/1.1
> Host: 127.0.0.1:7100
> Cookie: user_token=del
> Content-Type: multipart/form-data; boundary=X-INSOMNIA-BOUNDARY
> User-Agent: insomnia/2023.5.8
> Accept: */*
> Content-Length: 215
| --X-INSOMNIA-BOUNDARY
| Content-Disposition: form-data; name="xxx"
| blah
| --X-INSOMNIA-BOUNDARY
| Content-Disposition: form-data; name=""; filename="1.txt"
| Content-Type: text/plain
| 555
| --X-INSOMNIA-BOUNDARY--
bb.on('file', (name, file, info) => {
console.log('name', name);
console.log(typeof name); // undefined
I don't maintain typings for any of my projects, so you would need to contact whoever is maintaining those for busboy.