s***@topnet.net.cn
s***@topnet.net.cn
  • 发布:2023-07-24 16:43
  • 更新:2024-04-25 11:33
  • 阅读:736

微信小程序:使用uni.downloadFile 、uni.saveFile下载的附件保存在手机的什么地方了?

分类:uni-app

需求:下载附件
结果:使用的uni.downloadFile 、uni.saveFile,下载后在手机文件中找不到
方法:

// 下载附件  
    downloadFun() {  
      //加载框动画  
      uni.showLoading({ title: '正在下载……' });  
      uni.downloadFile({  
        url: this.fileUrl, //下载地址接口返回  
        success: (data) => {  
          console.log(data, 'downloadFile-success');  
          if (data.statusCode === 200) {  
            //隐藏加载框  
            uni.hideLoading();  
            //文件保存到本地  
            uni.saveFile({  
              tempFilePath: data.tempFilePath, //临时路径  
              success: (red) => {  
                console.log(red, 'saveFile');  
                uni.showModal({  
                  title: '提示',  
                  content: '文件已保存:' + red.savedFilePath,  
                  cancelText: '我知道了',  
                  confirmText: '打开文件',  
                  success: function (res) {  
                    console.log(res, 'showModal');  
                    if (res.confirm) {  
                      uni.openDocument({  
                        filePath: red.savedFilePath,  
                        success: (sus) => {  
                          console.log('成功打开', sus);  
                        },  
                      });  
                    }  
                  },  
                });  
                this.close();  
              },  
            });  
          }  
        },  
        fail: (err) => {  
          console.log(err);  
          uni.$u.toast('文件下载失败');  
        },  
      });  
    },
2023-07-24 16:43 负责人:无 分享
已邀请:
piaoyi_UI

piaoyi_UI - 【插件开发】【专治疑难杂症】【多款插件已上架:https://ext.dcloud.net.cn/publisher?id=193663(微信搜索飘逸科技UI小程序直接体验)】【骗子请绕道】问题咨询请加QQ群:120594820,代表作灵感实用工具小程序

你这个是临时路径

  • s***@topnet.net.cn (作者)

    请问怎么可以转为永久路径,微信小程序平台有处理方法么。或者有其他方式可以满足微信小程序下载文件到本地么?

    2023-07-24 18:10

rosstran

rosstran

请问解决了吗?

要回复问题请先登录注册