在调用 云调用 图片审核接口
错误代码 -501001
提示错误信息 openapi.security.imgSecCheck:fail source.on is not a function; at openapi.security.imgSecCheck api;
服务端代码
// 图片检查async function imgSecCheck(event) { console.log("imgSecCheck:"+event.value) try { const res = await cloud.openapi.security.imgSecCheck({ media: { header: { 'Content-Type': 'application/octet-stream' }, contentType: 'image/png', value: Buffer.from(event.value) } }) return res; } catch (err) { return err; }} |
小程序页面 端
// 上传图片-审核 checkUpload: function () { // 选择图片 wx.chooseImage({ count: 1, sizeType: ['compressed'], sourceType: ['album', 'camera'], success: function (res) { wx.showLoading({ title: '上传中', }) const filePath = res.tempFilePaths[0] // 上传图片 const cloudPath = 'my-image' + filePath.match(/\.[^.]+?$/)[0] wx.getFileSystemManager().readFile({ filePath: res.tempFilePaths[0], success: buffer => { wx.hideLoading() console.log(buffer); console.log(buffer.data) // 调用云调用 wx.cloud.callFunction({ name: 'openapi', data: { action:'imgSecCheck', value: buffer.data } }).then(imgRes => { console.log(imgRes); console.log(imgRes.result.errCode); if (imgRes.result.errCode == '87014') { wx.showToast({ title: '图片含有违法违规内容', icon: 'none' }) return } else { //图片正常 console.log("图片正常") wx.showToast({ title: '图片正常', icon: 'none' }) } }).catch(err => { // handle error console.log(err); }) },fail: e => { console.error(e) } }) } }) } |
求答疑,是我代码问题,还是 微信服务器问题?

抱歉是 wx-server-sdk 的问题,请升级下 wx-server-sdk 到最新版(1.2.2)再试试呢?
用 `cloud.DYNAMIC_CURRENT_ENV` 做的初始化?
可以先试下老的初始化方式: