Created
October 21, 2018 05:55
-
-
Save dend/70e7cd3df057c3445325b8b054ca2229 to your computer and use it in GitHub Desktop.
Submit image to Face API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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