VPS参考测评推荐
专注分享VPS主机优惠信息
衡天云优惠活动
华纳云最新优惠促销活动
jtti最新优惠促销活动

微信小程序调用图片安全API(微信小程序检查图片安全)

locvps
主机参考:VPS测评参考推荐/专注分享VPS服务器优惠信息!若您是商家可以在本站进行投稿,查看详情!此外我们还提供软文收录、PayPal代付、广告赞助等服务,查看详情!
我们发布的部分优惠活动文章可能存在时效性,购买时建议在本站搜索商家名称可查看相关文章充分了解该商家!若非中文页面可使用Edge浏览器同步翻译!PayPal代付/收录合作

微信小程序被拒绝是因为用户上传图片时可能存在非法问题,程序必须具有审核机制。解决方案如下(云开发):config.json

{“权限“:{“open API“:【“安全性。imgsecheck“】}云函数

const cloud = require(‘wx-server -SDK’)cloud . init()exports . main = async(event,context)=》{ const { value } = event;try { const RES = await cloud . open API . security . imgseccheck({ media:{‘content -Type:‘‘application/octet -stream‘},content Type:‘image/png‘,value:buffer . from(value)} })return RES;} catch(err){ return err;}}js

choose image(){ wx . choose image({ count:1,size type:【‘original‘,compressed】,source type:【‘album‘】,Success:(RES)=》{ if(RES . temp files【0】& RES . temp files【0】。size》1024 * 1024){ wx . show toast({ title:‘图片不能大于1M‘,icon:‘none‘})return;}//检查图片wx . getfile system manager()。readfile({ file path:RES . tempfile paths【0】,success:buffer =》{ console . log(buffer . data)wx . cloud . call function({ name:‘check img‘,data: { value: buffer.data } })。然后(imgRes =》{ if(imgRes . result . errcode = =‘87014‘){ wx . show toast({ title:‘图片包含非法内容‘,Icon:‘none‘})return } else {//图片正常if(this . data . img list . length!= 0){ this . setdata({ img list:this . data . img list . concat(RES . tempfile paths)})} else { this . setdata({ img list:RES . tempfile paths })} } }),fail:err =》{ console . log(err)})});},推荐教程:“微信小程序”

以上是微信小程序调用图片安全API的细节。更多资讯请关注主机参考等相关文章!

这几篇文章你可能也喜欢:

本文由主机参考刊发,转载请注明:微信小程序调用图片安全API(微信小程序检查图片安全) https://zhujicankao.com/102325.html

【腾讯云】领8888元采购礼包,抢爆款云服务器 每月 9元起,个人开发者加享折上折!
打赏
转载请注明原文链接:主机参考 » 微信小程序调用图片安全API(微信小程序检查图片安全)
主机参考仅做资料收集,不对商家任何信息及交易做信用担保,购买前请注意风险,有交易纠纷请自行解决!请查阅:特别声明

评论 抢沙发

评论前必须登录!