Skip to content

Typings for field name #350

@topd5

Description

@topd5

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions