I tried to incorporate the Node js implementation of JQuery File Upload with Express 3. It uses Formidable middleware for parsing multi-part data which is not compatible with Express 3's body parser. Fortunately, there's a quick fix:
From Myk's explanation in StackOverflow, Express uses express.bodyParser() as a convenience method to wrap 3 parsers (express.json, express.urlencoded and express.multipart) into one.
//just replace express.bodyParser() with: app.use(express.json()); app.use(express.urlencoded());
From Myk's explanation in StackOverflow, Express uses express.bodyParser() as a convenience method to wrap 3 parsers (express.json, express.urlencoded and express.multipart) into one.
Alternative Solution:
Another approach is to redefine the multipart parser of Express (co elmigranto):var express = require('express'); var bodyParser = express.bodyParser; bodyParser.parse('multipart/form-data') = function(req, options, next) { //custom parser or: next(); } //don't forget to use the variable bodyParser in your configuration
No comments:
Post a Comment