首页 > busboy这个库在angular post之后没有发送消息

busboy这个库在angular post之后没有发送消息

我测试了3种事件(file, field, finish)但并没有接收到。

下面是我代码

$http({
    method : 'POST',
    url : mublAConfig.server + '/api/v3/user/friend',
    headers : {
        'Content-Type' : 'application/x-www-form-urlencoded',
        'Authorization' : access_token
    },
    transformRequest : function(obj) {
        var str = [];
        for (var p in obj) {
            str.push(encodeURIComponent(p) + '=' + encodeURIComponent(obj[p]));
        }
        return str.join('&');
    },
    data : {
        id : $scope.writes[0].input,
        say : $scope.writes[1].input
    }
}).success(function(data) {
    console.log('Received data : ', data);
}).error(function(data) {
    console.log('Error! ', data);
});

busboy是这么写的

req.busboy = new busboy({headers:req.headers});
req.pipe(req.busboy);
req.busboy.on('file', function(field, file, name) {
    console.log('file event');
});
req.busboy.on('field', function(name, value) {
    console.log('field event');
});
req.busboy.on('finish', function() {
    console.log('busboy finished');
});

怎么解决?

【热门文章】
【热门文章】