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

Without file not able to access fields in multipart/form-data type #4486

Closed
2 tasks done
vasu-rangpariya-xl opened this issue Dec 28, 2022 · 4 comments
Closed
2 tasks done

Comments

@vasu-rangpariya-xl
Copy link

Prerequisites

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

Fastify version

^4.6.0

Plugin version

No response

Node.js version

^16

Operating system

Linux

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

Ubuntu 22.04.1 LTS

Description

When we create route that accepts data as an multipart/form-data and when we don't pass file/binary in payload we are not able to access fields that is passed in body and also there is some kind of sequence like always we have to pass fields in first and last need to contain binary/file

Steps to Reproduce

  • create route that accepts multipart/form-data
  • try to access the form body with req.file()
  • now don't pass any file or binary just only pass fields which contains any type of data like ( string,int..etc )
  • then try to access that fields in req.file() / req.body anywhere it is not available

Expected Behavior

Should be able to access those fields in req.body although we don't pass any file or binary

@mcollina
Copy link
Member

Thanks for reporting!

Can you provide steps to reproduce? We often need a reproducible example, e.g. some code that allows someone else to recreate your problem by just copying and pasting it. If it involves more than a couple of different file, create a new repository on GitHub and add a link to that.

@imbhaskarn
Copy link

imbhaskarn commented Dec 30, 2022

Hey @mcollina I would like to work on this issue.

@mcollina
Copy link
Member

go for it

@climba03003
Copy link
Member

After looking at this issue again. The behavior is expected since request.file will trigger the body stream to resume and start parsing.
You are required to use either request.parts() or attachFieldsToBody if you like automatic process.

@climba03003 climba03003 closed this as not planned Won't fix, can't repro, duplicate, stale Jan 10, 2023
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

No branches or pull requests

4 participants