koa2-multiparty
v1.0.1
Published
multiparty middleware for koa2 only
Downloads
12
Readme
koa2-multiparty
It's similar to connect-multiparty, but koa2-multiparty is for KOA2 only.
This middleware will create temp files on your server and never clean them up. Thus you should not add this middleware to all routes; only to the ones in which you want to accept uploads. And in these endpoints, be sure to delete all temp files, even the ones that you don't use.
Usage
const multiparty = require('koa2-multiparty');
router.post('/upload', multiparty(), function(ctx) {
console.log(ctx.req.body, ctx.req.files);
// don't forget to delete all req.files when done
});
If you pass options to multiparty()
, they are passed directly into
multiparty.