npm install koa-formidableFormidable middleware for Koa
[![NPM][npm]](https://npmjs.org/package/koa-formidable)
[![Dependency Status][dependencies]](https://david-dm.org/rkusa/koa-formidable)
Breaking Change in 1.0.0: both body and files are now added to Koa's .request instead of modifying the http request (.req) directly.
var formidable = require('koa-formidable')
Returns the formidable middleware that parses the incoming request and adds the .request.body and .request.files to the context.
Arguments:
* opts - the options that get passed to the Formidable.IncomingForm (you could also provide an instance of IncomingForm directly)
Example:
``js`
var formidable = require('koa-formidable')
app.use(formidable())
Parse the incoming request manually.
Arguments:
* opts - the options that get passed to the Formidable.IncomingForm (you could also provide an instance of IncomingForm directly)
* ctx - the Koa context
Example:
`js`
var formidable = require('koa-formidable')
app.use(function*(next) {
var form = yield formidable.parse(this)
...
yield next
})
Example:
`js``
var form = new require('formidable').IncomingForm()
form.on('progress', function(bytesReceived, bytesExpected) {
console.log(bytesReceived, bytesExpected)
})
var result = yield formidable.parse(form, this)