https://github.com/lizouzt/koa-formidable-yield
https://github.com/lizouzt/koa-formidable-yield
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/lizouzt/koa-formidable-yield
- Owner: lizouzt
- License: mit
- Created: 2016-04-14T16:52:38.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2016-04-14T17:22:41.000Z (about 9 years ago)
- Last Synced: 2025-03-11T01:54:11.638Z (3 months ago)
- Language: JavaScript
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# koa-formidable-yield
[](https://travis-ci.org/lizouzt/koa-formidable)
[Formidable](https://github.com/felixge/node-formidable) middleware for Koa
**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.
## API
`var formidable = require('koa-formidable-yield')`
### formidable(opts)
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`](https://github.com/felixge/node-formidable#formidableincomingform) (you could also provide an instance of `IncomingForm` directly)
**Example:**
```js
var formidable = require('koa-formidable-yield')
app.use(formidable())
```### formidable.parse(opts, ctx)
Parse the incoming request manually.
**Arguments:**
* **opts** - the options that get passed to the [`Formidable.IncomingForm`](https://github.com/felixge/node-formidable#formidableincomingform) (you could also provide an instance of `IncomingForm` directly)
* **ctx** - the Koa context**Example:**
```js
var formidable = require('koa-formidable-yield')
app.use(function*(next) {
var form = yield formidable.parse(this);
var files = form.files;
var fields = form.fields;
...
yield next
})
```## MIT License
Copyright (c) 2016