node-formidable / formidable

The most used, flexible, fast and streaming parser for multipart form data. Supports uploading to serverless environments, AWS S3, Azure, GCP or the filesystem. Used in production.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Attach fields to req.body and files to req.files like multer

dawkaka opened this issue · comments

Support plan

Community

  • which support plan is this issue covered by? Community
  • _is this issue currently blocking your project? yes

Context

Allow access to fields and files by attaching them to req body.

What problem are you trying to solve?

So fields and fields are accessible in middlewares

    app.post('/upload-formidable', (req, res, next) => {
        const form = formidable({});
        // this is fine
        form.parse(req, (err, fields, files) => {
            res.json({ fields, files });
        });
       // but should also be able to do this
       req.body    // should be fields object
       req.files // should be files object
    });

Do you have a new or modified API suggestion to solve the problem?

No