// 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)
转 : https://developers.weixin.qq.com/community/develop/doc/000e0a8ba305f067ac397176b56800