Window
Express 4.12.4
Multer 1.0.1
Node v0.10.22
I am trying to send a file to my node.js server using a postman.
I am trying to execute readme here
Here is what I am sending with the postman:
POST /ingest HTTP/1.1 Host: localhost:3000 Cache-Control: no-cache Postman-Token: 69dd2497-2002-56ed-30a4-d662f77dc0b0 Content-Type: multipart/form-data; boundary=
Here's what it looks like: 
Here is what it clicks on node.js
var Ingest = require('../controllers/ingest.js'); var multer = require('multer'); var upload = multer({ dest: 'uploads/',fileFilter:function(req,file,cb){ console.log('file is',file) cb(null,true); } }); module.exports = function (app) { app.post('/ingest', upload.single('test'), function(req, res, next) { console.log(req.body); console.log(req.file); Ingest.ingestData() .then(function (response){ return res.status(200).json(response); }); }); }
When I find this route with the postman, I get {} for req.body and undefined for req.file .
What am I doing wrong?
Here, where I initialize the app , which is passed to the route file:
var express = require('express'); var app = express(); var http = require('http'); var cfg = require('./config')(); var passport = require('passport'); var cors = require('cors'); var bodyParser = require('body-parser'); app.set('port', process.env.PORT || cfg.port); var corsOptions = { origin: "*", allowedHeaders: ['Content-Type', 'Authorization', 'Accept', 'x-reset-token', 'x-invite-token', 'x-api-key', 'x-www-form-urlencoded'], credentials: true }; app.use(cors(corsOptions)); app.use(bodyParser.json()); app.use(bodyParser.urlencoded({ extended: true })); app.use(passport.initialize()); http.createServer(app).listen(app.get('port'), function(){ console.log('Express server listening on port ' + app.get('port')); });
Maybe something is doing there?
Edit:
I even tried
var Ingest = require('../controllers/ingest.js'); var multer = require('multer'); var upload = multer({ dest: 'uploads/',fileFilter:function(req,file,cb){ console.log('file is',file) cb(null,true); } }).single('csv'); module.exports = function (app) { app.post('/ingest', function(req,res){ upload(req, res, function(err) { if(err){ console.log(err); } console.log(req.body); console.log(req.file); Ingest.ingestData() .then(function (response){ return res.status(200).json(response); }); }); }); }
And it didn’t help. He writes nothing for err