1***@qq.com
1***@qq.com
  • 发布:2023-08-05 10:03
  • 更新:2023-08-05 10:03
  • 阅读:332

【报Bug】uni.chooseImage返回的路径在手机文件夹中找不到

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: windows11

HBuilderX类型: 正式

HBuilderX版本号: 3.8.7

手机系统: Android

手机系统版本号: Android 11

手机机型: CRUISE2 5G

页面类型: vue

vue版本: vue2

打包方式: 云端

项目创建方式: HBuilderX

示例代码:
uni.chooseImage({  
        count: thisNum,  
        sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有  
        sourceType: this.sourceType,  
        success: (res) => {  
          console.log(res);  
          if (res.tempFilePaths && res.tempFilePaths.length) {  
            this.deleteTemList.push(...res.tempFilePaths);  
           this.imgCompress(filePaths, 0);  
          } else {  
            this.$u.toast(`获取照片路径失败${JSON.stringify(res)}`, 1500);  
          }  
        },  

imgCompress(tempFilePaths, type) {  
      if (tempFilePaths && tempFilePaths.length) {  
        //type 0 为图片 1为视频  
        uni.showLoading({  
          title: '压缩中...',  
          mask: true,  
        });  
        let compressImgs = [];  
        let results = [];  
        tempFilePaths.forEach((item, index) => {  
          compressImgs.push(  
            new Promise((resolve, reject) => {  
              // #ifndef H5  
              uni.compressImage({  
                src: item,  
                quality: this.quality,  
                success: (res) => {  
                  // _doc/uniapp_temp_1689576424122/compressed/1689576436111_1689576431900.jpg  
                  if (res.tempFilePath) {  
                    results.push(res.tempFilePath);  
                    resolve(res.tempFilePath);  
                  } else {  
                    this.$u.toast(`压缩路径${item}失败,压缩错误码为${JSON.stringify(res)}`);  
                  }  
                },  
                fail: (err) => {  
                  if (err.errMsg == 'compressImage:fail 文件不存在') {  
                    this.$u.toast('相机错误,建议重启app');  
                  } else {  
                    this.$u.toast(`压缩失败1${JSON.stringify(err)}`, 1500);  
                  }  
                  reject(err);  
                },  
                complete: () => {  
                  //uni.hideLoading();  
                },  
              });  
              // #endif  
            }),  
          );  
        });  
        Promise.all(compressImgs) //执行所有需请求的接口  
          .then((results) => {  
            console.log(results);  
            uni.hideLoading();  
            if (results.length) {  
              this.imgUpload(results, type);  
            } else {  
              this.$u.toast(`未获取到压缩后的图片路径,请重试${JSON.stringify(results)}`);  
            }  
          })  
          .catch((res, object) => {  
            if (res.errMsg == 'compressImage:fail 文件不存在') {  
              this.uploadEmpty();  
            } else {  
              this.$u.toast(`压缩失败2${JSON.stringify(res)}`, 1500);  
            }  
            uni.hideLoading();  
          });  
      } else {  
        this.$u.toast('未传入压缩图片路径,请重试');  
      }  
    },

操作步骤:

使用手机拍照,偶然会出现照片存不进去的情况

预期结果:

照片应该能存进去

实际结果:

在文件夹中找不到照片

bug描述:

拍照上传照片时,根据uni.chooseImage返回的路径人工在文件中找不到该照片,压缩时也找不到,提示{"errMsg"."compresslmage:fail文件不存在""errCode":-4"code":-4) ,经过清除软件缓存后又恢复正常 ,怀疑可能是app的某些缓存机制影响了存储

2023-08-05 10:03 负责人:无 分享
已邀请:

该问题目前已经被锁定, 无法添加新回复