Closed lrbmike closed 7 years ago
please use https://github.com/cojs/busboy to parse multipart body
@dead-horse
finally I use https://github.com/GaryChangCN/koa2-formidable that koa2 middleware for formidable to fix the issue.
and it must parse before , the code like this:
const formidable = require('koa2-formidable'); app.use(formidable()); const bodyparser = require('koa-bodyparser'); app.use(bodyparser());
Thanks
koa-bodyparser: 4.2.0 koa: 2.x
when post "x-www-form-urlencoded "data can work, but "multipart/form-data" don't.
in my code, I get the post data like this.
ctx.request.body.xxx
and "ctx.request.body" as follows.
{ "------WebKitFormBoundaryVBuCsc3223WYXwYy\r\nContent-Disposition: form-data; name": "\"aaaaa\"\r\n\r\n11111\r\n------WebKitFormBoundaryVBuCsc3223WYXwYy\r\nContent-Disposition: form-data; name=\"bbbbb\"\r\n\r\n222222\r\n------WebKitFormBoundaryVBuCsc3223WYXwYy--\r\n" }
also i try to add "extendTypes", but it doesn't work.
app.use(bodyparser({ extendTypes: { form: ['multipart/form-data'] } }));
how i can get the "multipart/form-data" data?