Express 为什么我在试图用busboy解析POST请求时没有定义?使用MEAN.IO堆栈

Express 为什么我在试图用busboy解析POST请求时没有定义?使用MEAN.IO堆栈,express,middleware,mean.io,Express,Middleware,Mean.io,我正在尝试使用busboy connect解析发送到服务器的请求文件。当我打印出我的请求对象时,我得到这个巨大的Angular.identity对象,当我尝试使用以下代码解析该对象时: app.post("/compositions/fileUpload", function(req, res){ var fstream; req.pipe(req.busboy); req.busboy.on('file', function (fieldname, file, file

我正在尝试使用busboy connect解析发送到服务器的请求文件。当我打印出我的请求对象时,我得到这个巨大的Angular.identity对象,当我尝试使用以下代码解析该对象时:

app.post("/compositions/fileUpload", function(req, res){
var fstream;

     req.pipe(req.busboy);

     req.busboy.on('file', function (fieldname, file, filename) {

        console.log("Uploading: " + filename); 

        fstream = fs.createWriteStream('/files/' + filename);

        file.pipe(fstream);

        fstream.on('close', function () {

            res.redirect('back');

        });
    });
我在“请求管道(请求总线男孩)”上出错。我确实需要连接服务生和fs。我还确保告诉我的应用程序使用巴士男孩,所以他们应该在那里。但是,我仍然会遇到以下错误:

TypeError: Cannot call method 'on' of undefined
    at IncomingMessage.Readable.pipe (_stream_readable.js:476:8)
    at Object.handle (/home/cyen/development/composelet/source/composelet/packages/compositions/server/routes/compositions.js:38:10)
    at next_layer (/home/cyen/development/composelet/source/composelet/node_modules/express/lib/router/route.js:103:13)
    at Route.dispatch (/home/cyen/development/composelet/source/composelet/node_modules/express/lib/router/route.js:107:5)
    at /home/cyen/development/composelet/source/composelet/node_modules/express/lib/router/index.js:213:24
    at Function.proto.process_params (/home/cyen/development/composelet/source/composelet/node_modules/express/lib/router/index.js:286:12)
    at next (/home/cyen/development/composelet/source/composelet/node_modules/express/lib/router/index.js:207:19)
    at next (/home/cyen/development/composelet/source/composelet/node_modules/express/lib/router/index.js:182:38)
    at next (/home/cyen/development/composelet/source/composelet/node_modules/express/lib/router/index.js:182:38)
    at next (/home/cyen/development/composelet/source/composelet/node_modules/express/lib/router/index.js:182:38)
POST /compositions/fileUpload 500 136.347 ms - -

_stream_readable.js:483
    dest.end();
         ^
TypeError: Cannot call method 'end' of undefined
    at IncomingMessage.onend (_stream_readable.js:483:10)
    at IncomingMessage.g (events.js:180:16)
    at IncomingMessage.EventEmitter.emit (events.js:92:17)
    at _stream_readable.js:920:16
    at process._tickCallback (node.js:415:13)
我不知道为什么。似乎还有另一个与我类似的问题,但尚未解决。有人知道这个错误是由什么引起的吗?
谢谢

问题是我在全局范围内不需要(连接总线男孩)在我的模块上方。

我也有同样的问题。你能再解释一下吗?为了让这个例子起作用,我应该添加什么?好吧,我的问题是我没有包括connect busboy。我的错误是找不到undefined的方法“on()”,这是因为我实际上没有包含connect busboy模块。因此,为了解决这个问题,在我的express文件的顶部,我简单地说:require('connect-busboy');