Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multipart: Boundary not found #304

Closed
2 tasks done
tc-root-user opened this issue Dec 8, 2021 · 5 comments · Fixed by #305
Closed
2 tasks done

Multipart: Boundary not found #304

tc-root-user opened this issue Dec 8, 2021 · 5 comments · Fixed by #305

Comments

@tc-root-user
Copy link

tc-root-user commented Dec 8, 2021

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the bug has not already been reported

Fastify version

3.24.1

Plugin version

5.2.0

Node.js version

16.5.0

Operating system

Linux

Operating system version (i.e. 20.04, 11.3, 10)

Ubuntu 20.04

Description

When the file limit size is set, then headers are a mandatory prop. The code should be something like:

await req.file({
    headers: { "content-type": "multipart/form-data" },
    limits: {
        fileSize: (1024 * 1024) * 55
    }
})

The issue begins with passing those content-type at the request (as they are mandatory now), then the server responds with error 500 and the message "Multipart: Boundary not found".

Steps to Reproduce

1 - Make a file upload;
2 - Set some limit to the upload throught req.file(PROPS);
3 - Verify that the headers are mandatory now;
4 - Pass the respective header throught request;
5 - Try to do the upload;
6 - Observe that the server responds with error 500 with the message "Multipart: Boundary not found".

Expected Behavior

The upload happens normally respecting the file size limit.

@kibertoad
Copy link
Member

@Uzlopak

@climba03003
Copy link
Member

climba03003 commented Dec 8, 2021

The main problem is the user must not pass the headers to option.

{ headers: Object.assign({}, request.headers) },

The headers should be passed using request.headers. and it is handled by this plugin already.

My command here is correct, it is a breaking change if you force the user to pass the headers.
#300 (comment)

@kibertoad
Copy link
Member

I'll produce a fix shortly.

@kibertoad kibertoad mentioned this issue Dec 8, 2021
4 tasks
@kibertoad
Copy link
Member

kibertoad commented Dec 8, 2021

@tc-root-user Can you please check with 5.2.1 (with removed explicit header)?`

@tc-root-user
Copy link
Author

@tc-root-user Can you please check with 5.2.1 (with removed explicit header)?`

Working as expected!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants