Skip to content

lizouzt/koa-formidable-yield

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

koa-formidable-yield

Build Status

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 (you could also provide an instance of IncomingForm directly)

Example:

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 (you could also provide an instance of IncomingForm directly)
  • ctx - the Koa context

Example:

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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published