云函数调用imgSecCheck,工具能上传图片并检测成功,为什么真机上传不了图片了?
AppID(小程序ID): wx3fd730ac1e1a9003
// 上传图片
async uploadAvatar() {
let upToken = await this.getQiniuToken()
let that = this
wepy.chooseImage({
sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有
sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
count: 9 // 默认9
}).then(res => {
let tempFilePaths = res.tempFilePaths
tempFilePaths.forEach(function (item, index) {
wx.getFileSystemManager().readFile({
filePath: item,
success: res => {
let Buffer = res.data
wx.cloud.callFunction({
name: 'ContentCheck',
data: {
img: Buffer
},
success(res) {
if(res.result.errCode === 87014){
Toast('图片违规!')
return false
} else {
if (upToken) {
wepy.showLoading({
title: '正在上传...'
})
qiniuUploader.upload(
item,
qiniuRes => {
wepy.hideLoading()
if (that.myPublishList.affordNeedImg.length < 9) {
that.myPublishList.affordNeedImg.push(qiniuRes.imageURL)
that.$apply()
}
wepy.showToast({
title: `上传图片成功`,
icon: 'none'
})
},
error => {
console.log(error)
wepy.hideLoading()
wepy.showToast({
title: `error: ${JSON.stringify(error)}`,
icon: 'none'
})
},
{
region: 'ECN',
uptoken: upToken,
key: `GShangxie/${new Date().getTime()}.png`,
uploadUrl: 'https://up.qiniup.com',
domain: 'https://htpic.fangxie365.com'
}
)
}
}
}
})
}
})
})
})
},