opensource
opensource copied to clipboard
Can't make the multipart work with koa-router
I'm on [email protected]
, [email protected]
and [email protected]
.
Trying to disable multipart for all the routes except /profilepic
.
app.use(body({
multipart: false,
strict: false
}))
router.post('/profilepic',
body({
multipart: true,
uploadDir: path.resolve(__dirname, '../../../uploads')
}),
this.changeProfilePicture
)
with this code changeProfilePicture
is never called. It works if I remove the body()
from the router and use multipart: true
on app.use
.
actually even router.post('/profilepic', body(), this.changeProfilePicture)
doesn't work, with or wihtout app.use(body())
.
Hmm.. strange, don't know. Can you please try koa-better-router? It's almost the same (and even more better) and is guaranteed to work with this version of koa-better-body
.
It was working, probably some new versions of koa-router
do something, i don't following it.
you don't have to disable multipart because this module doesn't provide ctx.request.fields
only when the request is multipart/form-data. so you could just parse body without handling multipart