Skip to content

Middleware for handling `multipart/form-data` for koa, based on Express's multer.

License

Notifications You must be signed in to change notification settings

techanon/kuma-multer

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

kuma-multer

Multer is a node.js middleware for handling multipart/form-data for koa.
Alternative multer wrapper for koa v2's middleware using the async/await structure.

Uses Proxy instead of a plain function wrapper.
Tests are from koa-multer, but updated to modern node syntax.

Made with Nodejs v8 (untested against v6 --harmony, but might work)

NPM version License

Install

$ npm install --save kuma-multer

Usage:

const Koa = require('koa');
const Router = require('koa-router');
const Multer = require('kuma-multer');

const app = new Koa();
const router = new Router();

let upload = Multer({ dest: 'uploads/' });

router.post('/profile', upload.single('avatar'));
router.post('/profile/photos', upload.array('list'));

app.use(router.routes());
app.listen(3000);

Files are available via ctx.req.files or ctx.request.files.
If there is only one file, remove the plurality. (eg. ctx.req.file)
Any text fields are available via ctx.req.body or ctx.request.body.

License

MIT

About

Middleware for handling `multipart/form-data` for koa, based on Express's multer.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%