koajs / bodyparser

Koa body parsing middleware
MIT License
1.31k stars 116 forks source link

Unable to parse files from multipart/form-data request #94

Closed amrendraw3 closed 6 years ago

amrendraw3 commented 6 years ago

I am not able to parse files from 'content-type': 'multipart/form-data requests. I am not seeing any example so I am creating this issue.

I tried to parse through ctx.request.files & ctx.request.body.files but both return undefined

I am using: "koa": "^2.3.0" "koa-bodyparser": "4.2.0" node: v7.10.1 npm: 4.2.0

dead-horse commented 6 years ago

please use https://github.com/cojs/busboy to parse multipart/form-data file.

chrisveness commented 6 years ago

Might be worth mentioning in the README that koa-bodyparser doesn't handle enctype="multipart/form-data" :)

(edit: or incorporate PR #91?).

amrendraw3 commented 6 years ago

I used koa2-formidable package and able to parse files from request data.

niftylettuce commented 5 years ago

Please use @koa/multer instead at https://github.com/koajs/multer

mqliutie commented 4 years ago

@niftylettuce @koa/multer can not handle this problem. ctx.request.files is undefined when http request data upload like below image

but it work when upload like image

I don't know what different of them

AaronConlon commented 2 years ago

I used koa2-formidable package and able to parse files from request data.

  • In app.js var formidable = require('koa2-formidable'); app.use (formidable ({}))
  • ctx.request.files contains the files from request data

I use koa-body.