线上一直用对象存储上传图片都很正常,但是最近客户反应图片老上传失败,,返回undefined,,,求解答
wx.chooseMedia({
count: maxNum - currentNum,
mediaType: ['image'],
sizeType: ['original', 'compressed'],
success: (res) => {
console.log(res, '图片');
res.tempFiles.map(v => {
let fileUrl = v.tempFilePath
wx.compressImage({
src: fileUrl, // 图片路径
quality: 80, // 压缩质量
success(url) {
console.log(url, '2222====================')
let filePath = url.tempFilePath
if (filePath) {
var Key = util.getRandFileName(filePath);
wx.showLoading({
title: '正在上传...'
});
cos.postObject({
Bucket: config.Bucket,
Region: config.Region,
Key: currentDate + '/images/' + Key,
FilePath: filePath,
}, (err, data) => {
wx.hideLoading();
console.log(data,'data==========')
if (data && data.Location) {
console.log('https://' + data.Location)
let V_BACKGRADE = 'https://' + data.Location
var imgList = that.data.imgList
imgList.push(V_BACKGRADE)
that.setData({
V_BACKGRADE: imgList,
imgList: imgList
})
console.log(that.data.imgList, 'imgList')
} else {
wx.showToast({
title: '上传失败',
icon: 'error',
duration: 2000
});
}
});
}
}
})
})
}
})