Skip to content

Instantly share code, notes, and snippets.

@dend
Created October 21, 2018 05:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dend/70e7cd3df057c3445325b8b054ca2229 to your computer and use it in GitHub Desktop.
Save dend/70e7cd3df057c3445325b8b054ca2229 to your computer and use it in GitHub Desktop.
Submit image to 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
},
body: buff
}, function (err, httpResponse, body) {
console.log(body);
});
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment