I want to send Octet-Stream binary data to Microsoft Face API in Nodejs. I have a base64 encoded image data. I want to send it to the Face API. I'm using the following code:
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);
});
})
}
But it gives me this response:
{
"error": {
"code":"InvalidImageSize",
"message":"Image size is too small."
}
}