html52.com
我爱小程序-开发者交流社区

调用cloud.openapi.ocr.bankcard 一直报错?errCode: 41005


// 调用js 代码


bankOCR() {

    const that = this
    wx.chooseImage({
      count: 1,
      sizeType: ['compressed'],        
      sourceType: ['album', 'camera'], 
      success: function(res) {
        var tempFilePaths = res.tempFilePaths[0]
 
        let buffer = wx.getFileSystemManager().readFileSync(tempFilePaths)
        wx.cloud.callFunction({
          name: 'bank_ocr',
          data: { buffer:buffer }
        }).then(
          r => {
            console.log(r)
          }
        ).catch(res=>{
          console.log(res)
        })
      }
    })
  },



// 云函数入口文件

// 云函数入口文件
const cloud = require('wx-server-sdk')
 
cloud.init()
 
// 云函数入口函数
exports.main = async(event, context) => {
 
    let result = await cloud.openapi.ocr.bankcard({
      type: 'photo',
      // imgUrl: encodeURIComponent('https://static.shop.58victory.com/test/WechatIMG1327.jpeg')
      img : {
        contentType: 'image/jpeg',
        value: Buffer.from(event.buffer)
      }
    }).then(res => {
      console.log(res)
      return res.number
    }).catch(res => {
      console.log(res)
      return res
    })
    return result
}

报错 :Error: errCode: 41005  | errMsg: openapi.ocr.bankcard:fail media data missing hint:

请官方大大支持下。

通过imgUrl的方式是可以识别的,但是通过img的方式就一直报错。fail media data missing


网友回复

牛:

后台配置有问题,已修复。

感谢反馈。

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

真正的个人免签约支付接口

云免签H5支付