我想将Octet-Stream二进制数据发送到Nodejs中的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."
}
}
答案 0 :(得分:0)
而不是
uSoup = BeautifulSoup(b.text, 'html.parser')
data = uSoup.find_all('script')[16].string
做
request.post({
data: buff
}