koajs / bodyparser

Koa body parsing middleware

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to parse files from multipart/form-data request

amrendraw3 opened this issue · comments

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

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

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

(edit: or incorporate PR #91?).

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

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

@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

commented

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.