真机调试给腾讯云对象存储存图片正常 ? 但是预览的就是上传失败?
真机调试给腾讯云对象存储存图片正常 但是预览的就是上传失败 ,真机调试和预览都可以拿到临时密钥 afterRead(event) { console.log(event) var cos = new COS({ getAuthorization: function (options, callback) { wx.request({ url: 'http://192.168.101.26:8000/api/credential/', data: { // 可从 options 取需要的参数 }, success: function (result) { var data = result.data; var credentials = data.credentials; callback({ TmpSecretId: credentials.tmpSecretId, TmpSecretKey: credentials.tmpSecretKey, XCosSecurityToken: credentials.sessionToken, ExpiredTime: data.expiredTime, }); } }); } }); // 上传图片 var that=this //获取随机文件名 let randowString = Math.random().toString(36).slice(-8) + String(new Date().getTime()); var fileKey = randowString ; cos.postObject({ Bucket: 'chengxian-1303891317', Region: 'ap-nanjing', Key: fileKey+'.jpg', FilePath: event.detail.file.url, onProgress: function (info) { } }, function (err, data) { if (err) { console.log(err) wx.showToast({ title: '上传失败', icon: 'none' });}else{ that.setData({ fileList:that.data.fileList.concat(event.detail.file) }) that.data.coslist={} that.data.coslist.cos_path=data.headers.Location that.data.coslist.cos_name=fileKey+'.jpg' that.data.imageList.push(that.data.coslist) console.log(that.data.imageList) } });