Reputation: 9901
I have this nodejs application. Very simple.
var express = require('express');
var multer = require('multer');
var upload = multer({ dest: 'c:\\temp\\crnode\\' });
var app = express();
app.set('port', (process.argv[2] || 64312));
// alive check
app.get('/youalive', function(req, res) {
res.send('yup');
});
app.post('/cruseritems/put', upload.single('useritem'), function (req, res, next) {
console.log(req.file);
console.log(req.files);
res.status(204).end();
});
var port = app.get('port');
app.listen(port, function() {
console.log('Listening to ' + port + '...');
});
I borrowed this code from the github site itself (here). It does not work. No matter how I configure the client request, req.file
, req.body
, and req.files
are always undefined. What am I doing wrong?
I am using PostMan to generate requests. Here is the last request I tried:
POST /cruseritems/put HTTP/1.1
Host: thm02426:64312
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW
Cache-Control: no-cache
Postman-Token: b9afba7c-3c5d-9144-13d3-5ea1b4a203a4
----WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="useritem"; filename="dhtmled0_.pdf"
Content-Type: application/pdf
----WebKitFormBoundary7MA4YWxkTrZu0gW
Upvotes: 0
Views: 514