I am trying to pass a request object from my routes to a controller that handles downloads,
here is the route -
app.post('/upload/notes',auth.requiresApiLogin,function(req,res){
upload.file(req,res);
});
here is the controller code (upload.js) that has the exported file method
var fs = require('fs'),
uuid = require('node-uuid'),
path = require('path'),
Busboy = require('busboy');
exports.file = function(req, res) {
var busboy = new Busboy({ headers: req.headers});
busboy.on('file', function(fieldname, file, filename,transferEncoding,mimeType) {
console.log("inside upload function");
console.log(file);
});
busboy.on('field', function(fieldname, val, valTruncated,keyTruncated) {
console.log("inside field function");
console.log(fieldname);
});
busboy.on('finish',function(){
console.log('finished');
});
req.pipe(busboy);
};
So, what I see is that both the fields and the files are written to the console, but the finish event does not fire. What else should I try?
source
share