busboy icon indicating copy to clipboard operation
busboy copied to clipboard

Typings for field name

Open topd5 opened this issue 2 years ago • 1 comments

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 4busboy

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

topd5 avatar Nov 19 '23 11:11 topd5

I don't maintain typings for any of my projects, so you would need to contact whoever is maintaining those for busboy.

mscdex avatar Nov 19 '23 14:11 mscdex