如何在Node.js中将application/octet-steam图像数据发送到Microsoft Face API?

How to send application/octet-steam image data to Microsoft Face API in Node.js?

我想在 Nodejs 中将 Octet-Stream 二进制数据发送到 Microsoft Face API。我有一个 base64 编码的图像数据。我想把它发送到 Face API。我正在使用以下代码:

var dataURItoBuffer = function (dataURL, callback) {
    var buff = new Buffer(dataURL.replace(/^data:image\/(png|gif|jpeg);base64,/, ''), 'base64');
    callback(buff);
};

var sendImageToMicrosoftDetectEndPoint = function (imageData, callback) {
    console.log('Entered helper');
    dataURItoBuffer(imageData, function (buff) {
        request.post({
            url: keyConfig.microsoftDetectURL,
            headers: {
                'Content-Type': 'application/octet-stream',
                'Ocp-Apim-Subscription-Key': keyConfig.microsoftApiKey
            },
            data: buff
        }, function (err, httpResponse, body) {
            console.log(body);
        });
    })
}

但它给了我这样的回应:

{
  "error": {
     "code":"InvalidImageSize",
     "message":"Image size is too small."
   }
}

而不是

request.post({
    data: buff
}

request.post({
    body: buff
}