uniapp云存储{"errMsg":"cloudPath不合法"}
上传图片到云存储。
uni.chooseImage({
count:1,
success:res=>{
this.src=res.tempFilePaths[0]
console.log(res.tempFilePaths[0])
uniCloud.uploadFile({
filePath:res.tempFilePaths[0],
cloudPath:res.tempFilePaths[0]+res.tempFiles[0].name,
success: (res) => {
console.log(res)
},
fail: (err) => {
console.log(JSON.stringify(err))
}
})
}
})
报错:{"errMsg":"cloudPath不合法"}
原因:cloudPath
- 使用阿里云时,cloudPath为云端文件名,请勿使用非法字符
(cloudPath:res.tempFilePaths[0]+res.tempFiles[0].name-->是不合法的)
解决方法:改为cloudPath:res.tempFiles[0].name