导航栏: 首页 评论列表

nodejs response complete body

默认分类 2015/10/27 05:21

nodejs response complete body:

function uploadSingleImage(file, key, next) {
    var formdata = require('form-data');
    var form = new formdata();
    form.append('my_field', 'my value');
    form.append('file', file);

    form.submit({
        // host: 'api.img.ymatou.com',
        // port: 80,
        host: '172.16.2.172',
        port: 3000,
        path: '/api/Image/Upload?PicType=product',
        headers: {
            'x-test-header': 'test-header-value'
        }
    }, function (err, res) {
        console.log('>>>>uploadSingleImage callback\n');
        var body = '';
        res.on('data', function (chunk) {
            body += chunk;
        });
        res.on('end', function () {
            console.log(body);

            next(err, key, body);
        });

    });
}


>> 留言评论