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

微信小程序调用图片安全API(小程序加载图片)

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

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

{ 权限 :{ openapi :[ ;security.imgSecCheck ]}}云函数

const cloud = require( # 39;wx-server -SDK # 39;)cloud . init()exports . main = async(event,context)= gt;{ const { value } =事件;请尝试{ const RES = await cloud . open API . security . imgseccheck({ media:{ header:{ # 39;内容-类型 # 39;: '应用程序/octet -流 # 39;},内容类型: # 39;图片/png # 39;,value: Buffer.from(value) } })返回res} catch(err){ return err;}}js

choose image(){ wx . choose image({ count:1,size type:[ # 39;原创 # 39;, '压缩 # 39;],source type:[ # 39;相册 # 39;],成功:(RES)= gt;{ if(RES . temp files[0] ; res.tempFiles[0]。size gt1024 * 1024){ wx . show toast({ title: # 39;图片不能大于1M # 39,图标: # 39;无 # 39;})返回;}//查看图片wx.getfilesystemmanager()。readfile({ file path:RES . tempfile paths[0],success:buffer = >;{ console . log(buffer . data)wx . cloud . call function({ name: # 39;检查 # 39;,数据:{ value: buffer.data } })。然后(imgRes = gt{ if(imgres . result . errcode = = # 39;87014'){ wx . show toast({ title: # 39;图片包含非法内容 # 39;,图标: # 39;无 # 39;}) return} else {//图片正常if (this.data.imgList.length!= 0){ this . setdata({ img list:this . data . img list . concat(RES . tempfile paths)})} else { this . setdata({ img list:RES . tempfile paths })} } },fail:err = gt;{ console . log(err)} })});}、推荐教程:“微信小程序”以上是微信小程序调用图像安全API的详细内容。更多请关注主机参考其他相关文章!

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

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

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

评论 抢沙发

评论前必须登录!