node busboy + express 4 + ng-file-upload no desencadena eventos

Estoy usando mean.io stack + ng-file-upload

驴Alguien sabe por qu茅 los eventos no se activan?

cliente

controller('ArticleParentCtrl', ['$scope', '$timeout', '$upload', function ($scope, $timeout, $upload) { $scope.article = {}; function setPreview(fileReader, index) { fileReader.onload = function(e) { $timeout(function() { $scope.dataUrls[index] = e.target.result; }); }; } $scope.fileReaderSupported = window.FileReader !== null; $scope.uploadRightAway = true; $scope.hasUploader = function(index) { return (typeof $scope.upload[index] !== 'undefined'); }; $scope.abort = function(index) { $scope.upload[index].abort(); $scope.upload[index] = null; }; $scope.onFileSelect = function($files) { $scope.selectedFiles = []; $scope.progress = []; if ($scope.upload && $scope.upload.length > 0) { for (var i = 0; i < $scope.upload.length; i++) { if ($scope.upload[i] !== null) { $scope.upload[i].abort(); } } } $scope.upload = []; $scope.uploadResult = []; $scope.selectedFiles = $files; $scope.dataUrls = []; for (var y = 0; y  -1) { var fileReader = new FileReader(); fileReader.readAsDataURL($files[y]); setPreview(fileReader, y); } $scope.progress[y] = -1; if ($scope.uploadRightAway) { $scope.start(y); } } }; $scope.start = function(index) { $scope.progress[index] = 0; $scope.upload[index] = $upload.upload({ url :'/articles/api/upload', method: 'POST', headers: { 'x-ng-file-upload': 'lalista' }, data : $scope.media, file: $scope.selectedFiles[index], fileFormDataName: 'avatar' }) .then( function(response) { $scope.uploadResult.push(response.data); $timeout(function() { $scope.article.avatar = response.data.avatar; }); }, null, function(evt) { $scope.progress[index] = parseInt(100.0 * evt.loaded / evt.total); }) .xhr(function(xhr){ xhr.upload.addEventListener('abort', function(){ console.log('aborted complete'); }, false); }); }; }]) 

servidor

 exports.upload = function(req, res) { var busboy = new Busboy({ headers: req.headers }); busboy.on('error', function(err){ console.log(err); }); busboy.on('file', function(fieldname, file, filename, encoding, mimetype) { console.log('fieldname'); console.log(fieldname); console.log('file'); console.log(file); console.log('filename'); console.log(filename); console.log('encoding'); console.log(encoding); console.log('mimetype'); console.log(mimetype); //var saveTo = path.join(os.tmpDir(), path.basename(fieldname)); //file.pipe(fs.createWriteStream(saveTo)); }); busboy.on('finish', function() { console.log('finish'); }); }; 

Si uso formidable como:

 var form = new formidable.IncomingForm; form.parse(req, function(err, fields, files){ console.log(files); }); 

el c贸digo funciona bien, pero me gustar铆a saber que whay on earth con busboy no funciona 馃檨

Usted no est谩 canalizando su solicitud en busboy. Necesitas hacer req.pipe(busboy); .

Esto funciona para mi

busboy no dispara evento final

 var Busboy = require('busboy'); exports.upload = function(req, res) { var busboy = new Busboy({ headers: req.headers }); busboy.on('error', function(err) { console.log(err); }); busboy.on('file', function(fieldname, file, filename, encoding, mimetype) { console.log(fieldname); console.log(file); console.log(filename); console.log(encoding); console.log(mimetype); // see other question file.resume(); }); busboy.on('finish', function() { console.log('finish'); }); return req.pipe(busboy); };