云函数
const cloud = require('wx-server-sdk')
cloud.init()
exports.main = async (event, context) => {
try {
const result = await cloud.openapi.security.imgSecCheck({
media: {
header: {'Content-Type': 'application/octet-stream'},
contentType: 'image/jpg',
content: Buffer.from(event.value)
}
})
return result
} catch (err) {
return {
code: 10,
msg: '检测失败',
error: err
}
}
}
前端
wx.getFileSystemManager().readFile({
filePath: tempFilePath,
success: async (res) => {
const imgBase64 = res.data
try {
const checkRes = await cloudInstance.callFunction({
name: 'imgSecCheck',
data: {
value: imgBase64
}
})
} catch (err) {
}
},
})
一直报错 errCode: 47001, errMsg: "openapi.security.imgSecCheck:fail data format error rid: " 也参考了别人的评论里的代码,为什么不行?

你好,1.0接口已停止更新维护,建议使用2.0接口