javascript - 将base64用于自定义视觉节点js
问题描述
目前我可以使用 url 作为我的分类图像 URL,但我想改用 base64string。但是当我尝试这样做时,我收到了 BadRequestImageFormat 错误消息。我能做些什么?
app.post('/predict', function(req, res){
const predictionKey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
const endPoint = "https://southcentralus.api.cognitive.microsoft.com"
const projectId = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
const publishedName = "AntiScam";
const PredictionApiClient = require("azure-cognitiveservices-customvision-prediction");
const predictor = new PredictionApiClient(predictionKey, endPoint);
var data2 = req.body.img;
tempData={ url: data2 };
predictor.classifyImageUrl(projectId, publishedName, tempData)
.then((resultJSON) => {
console.log("RESULT ######################")
console.log(resultJSON);
res.send(resultJSON);})
.catch((error) => {
console.log("ERROR #####################");
console.log(error);}
);
});
解决方案
唯一受支持的请求是multipart/form-data
或者通过提供图像的 URL。所以不,似乎不支持 base64 字符串。
推荐阅读
- php - Magento:如何将商店设置转移到默认范围?
- ios - viewController 中所有对象的 iOS/Swift 位置在 .setBackgroundImage 之后重置
- node.js - SyntaxError:Exports.runInThisContext (vm.js:73:16) 处的意外令牌非法在 Module._compile (module.js:443:25)
- laravel - 在 laravel/lumen v5.6 中无法获取 AuthServiceProvider 中的标头
- docker - Docker 容器 DNS - 解析 URL
- javascript - 通过单击按钮创建文件夹和文件的网站功能
- python - 无法绑定 VBO 对象(未找到 glGenBuffers)
- java - 是否应该在 JavaDoc 中描述未经检查的异常?
- php - PHP excel来自MySQL DATABASE RECORDS
- java - 如何在双向关联 Spring 数据 JPA 中使用休眠版本控制?