openapi.ocr.printedText 今日不停地报 fail system error?
在开发过程中,偶尔报过一两次此类错误,但今日交接时,几乎达到了 100%。出现此类报错的原因是什么,和前端(小程序端)有关系么?
在开发过程中,偶尔报过一两次此类错误,但今日交接时,几乎达到了 100%。出现此类报错的原因是什么,和前端(小程序端)有关系么?
麻烦提供出现问题的具体机型、微信版本号、系统版本号,以及能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)
@是柿子啊 @Welkin
从其余帖子看,fail system error 可能是图片解码错误。目前使用的方式是上传图片至图床,腾讯服务器下载后再识别的方式。这流程可能在某些情况下表现不符合预期(频繁报 fail system error),打算改用 Buffer 的方式。
代码如下:
// item 为 chooseImage 返回的图片 pathlet buffer = wx.getFileSystemManager().readFileSync(item)wx.cloud.callFunction({ name: 'printedTextOCR', data: { buffer }}).then( r => { console.log(r) })// 云函数const cloud = require('wx-server-sdk')cloud.init()exports.main = async (event, context) => { return await cloud.openapi.ocr.printedText({ type: 'photo', img: { contentType: 'image/jpg', value: event.buffer } }).then(r => r).catch(e => e)} |
报如下错误:
errCode: 41005,errMsg: "openapi.ocr.printedText:fail media data missing hint: [Jo03914741]" |
请问官方,代码有什么问题么?
更新:云函数第八行改为
value: Buffer.from(event.buffer) |