开发环境:yzwdj
业主我当家:
appid=wx9f66c7f0543a6f00
生产环境已上线运行几个月,前两天出现不能上传本地文件至云存储,通过跟踪排查分析,发现是wx.cloud.uploadfile云函数报错:
报错内容:fail url not in domain list;at wx.cloud.uploadfile api
上传本地文件名为:wxfile://tmp????????.png
该程序过去在真机运行都一切正常,现在在微信开发者工具上调试也正常,但上传本地 文件格式为:http://tmp??????????.png
发现开发调试环境和真机运行环境在本地文件名格式上有差异,请问该如何解决?
程序片段代码:
wx.showLoading({
title: '封面上传中...',
})
wx.cloud.uploadFile({
cloudPath: 'owner_sound/share/' + that.data.news_id + '/share.jpg',
filePath: that.data.upload_local_url, // 本地文件路径
name: 'share',
success: res => {
var m_fileID=res.fileID
wx.hideLoading({
success: (res) => {
that.getImgUrl(m_fileID)
},
})
},
fail: err => {
that.setData({
publisher_change: false,
})
wx.hideLoading({
success: (res) => {
wx.showModal({
title: '封面图片上传失败!',
content: err.errMsg,
showCancel: false,
})
},
})
}
})
真机报错显示:
微信:13883166466,谢谢!
长期的方案:去掉 `app.json` 里的 `“cloud”: true` 配置项