Skip to content

Cannot upload file within FormData #4412

@Romick2005

Description

@Romick2005

Describe the bug

After upgrading from 0.24.0 to 0.25.0 File Form upload breaks.

To Reproduce

Original working on 0.24.0 code.

axios({
    method: "post",
    url: [serverUrl],
    data: formData, // FormData object instance with uploading file field
    timeout: 120000
});

This code was working previously, but now backend cannot extract file field.
After specifying content type:

axios({
    method: "post",
    url: [serverUrl],
    data: formData, // FormData object instance with uploading file field
    timeout: 120000,
    headers: {"Content-Type": "multipart/form-data"},
});

I got an error on backend "bad content-type header, no multipart boundary"

Expected behavior

Seems like previous version of axios (0.24.0) automatically add correct header and also boundary.
Or was there any breaking change that I didn't notice?

Environment

  • Axios Version [0.25.0]
  • Node.js Version [16.0.0]
  • Additional Library Versions [formidable 2.0.1, React-Native 0.66.4]

Additional context/Screenshots

Not needed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions