小程序ocr通过二进制上传识别出错openapi.ocr.vehicleLicense:fail media data missing

时间:2020-07-26 00:56:32   收藏:0   阅读:103

 

 

// item 为 chooseImage 返回的图片 path
let 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)

 

 

 

转 : https://developers.weixin.qq.com/community/develop/doc/000e0a8ba305f067ac397176b56800

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!