Permalink
Browse files

docs

  • Loading branch information...
1 parent 32b26bb commit 1ebbc93e40761d36eafc91c97b5fae52c34c42ca @tj tj committed Nov 17, 2011
Showing with 18 additions and 8 deletions.
  1. +18 −8 lib/middleware/bodyParser.js
@@ -30,10 +30,9 @@ function mime(req) {
/**
* Parse request bodies.
*
- * By default _application/json_ and _application/x-www-form-urlencoded_
- * are supported, however you may map `connect.bodyParser.parse[contentType]`
- * to a function of your choice to replace existing parsers, or implement
- * one for other content-types.
+ * By default _application/json_, _application/x-www-form-urlencoded_,
+ * and _multipart/form-data_ are supported, however you may map `connect.bodyParser.parse[contentType]`
+ * to a function receiving `(req, options, callback)`.
*
* Examples:
*
@@ -44,13 +43,24 @@ function mime(req) {
* }
* );
*
- * Since both _json_ and _x-www-form-urlencoded_ are supported by
- * default, either of the following requests would result in the response
- * of "viewing user tj".
- *
* $ curl -d 'user[name]=tj' http://localhost/
* $ curl -d '{"user":{"name":"tj"}}' -H "Content-Type: application/json" http://localhost/
*
+ * Multipart configuration:
+ *
+ * The `options` passed are provided to each parser function.
+ * The _multipart/form-data_ parser merges these with formidable's
+ * IncomingForm object, allowing you to tweak the upload directory,
+ * size limits, etc. For example you may wish to retain the file extension
+ * and change the upload directory:
+ *
+ * server.use(bodyParser({
+ * keepExtensions: true
+ * , uploadDir: '/www/mysite.com/uploads'
+ * }));
+ *
+ * View https://github.com/felixge/node-formidable for more information.
+ *
* @param {Object} options
* @return {Function}
* @api public

0 comments on commit 1ebbc93

Please sign in to comment.