收藏
回答

wx.cloud.uploadfile上传图片,在开发工具中正常,但在真机调试中报错 超时?

uploadImage(index){
    let that=this;
    //上传至微信云存储
    wx.cloud.uploadFile({
      //使用时间戳加随机数给图片命名
      cloudPath:'drinkImages/' + new Date().getTime() + "_" +  Math.floor(Math.random()*1000) + ".jpg",
      filePath:that.data.imgList[index],// 本地文件路径
      success: res => {
        // 返回文件 ID
        console.log("上传成功",res.fileID);
        that.data.imagesSuccessList[index] = res.fileID;
        that.data.imagesSuccessCount = that.data.imagesSuccessCount + 1;
        if(that.data.imagesSuccessCount == that.data.imgList.length){
          console.log("上传成功:", that.data.imagesSuccessList);
          that.uploadData();
          wx.hideLoading();
        } else {
          that.uploadImage(index+1);
        }
      },
      fail: err =>{
        wx.hideLoading();
        console.log("上传失败",err);
        that.setData({
          imagesSuccessList:[],
          imagesSuccessCount: 0
        })
        wx.showToast({
          icon:'none',
          title: '上传失败,请重新上传',
        })
      }
    }) 
  },
回答关注问题邀请回答
收藏
登录 后发表内容