form-data-parser
v0.0.3
Published
Middleware that parses FormData requests and places them on req.body
Downloads
477
Maintainers
Readme
form-data-parser
Middleware for connect or express that parses FormData in a sane way, no streams necessary.
Note: Originally made to work with the ember-cli-form-data addon.
Usage
npm install form-data-parser --save
var express = require('express');
var formDataParser = require('form-data-parser');
var app = express();
var fdp = formDataParser({
attrs: {
comments: 'array',
coverPhoto: 'dataUri'
}
});
/**
* Sent
* {
* blogPost: {
* comments: [1, 2],
* coverPhoto: formDataFile
* }
* }
*/
app.post('/api/blog-post', fdp, function (req, res) {
// req.body => { blogPost: comments: [1, 2], coverPhoto: 'data: image/png; base64, dasfe254....' }
});