收藏
回答

IOS下载xlsx文件成功并打开预览,但是如何发送分享文件和找到文件在手机端位置


IOS下载xlsx文件成功并打开预览,但是如何发送文件分享和找到IOS文件位置


util.js? [sm]:229 util request res=> {statusCode: 200, tempFilePath: "wxfile://tmp_b0e63e53a1b3d5ec406718bb6beedd77.xlsx", errMsg: "downloadFile:ok"}

14:20:15.089 DeliveryManagement.js? [sm]:508 downloadFile res=> {statusCode: 200, tempFilePath: "wxfile://tmp_b0e63e53a1b3d5ec406718bb6beedd77.xlsx", errMsg: "downloadFile:ok"}

14:20:15.090 DeliveryManagement.js? [sm]:519 newPat=> wxfile://usr/单据-2019-01-08).xlsx

14:20:15.320 DeliveryManagement.js? [sm]:541  wx.getFileSystemManager().rename err=> {errMsg: "rename:fail permission denied, open wxfile://tmp_b0e63e53a1b3d5ec406718bb6beedd77.xlsx"}

14:20:15.595 DeliveryManagement.js? [sm]:550 打开文档成功 res=> {errMsg: "openDocument:ok"}



使用 wx.downloadFile 接口获得变量 filePath  ,如下图


let filePath = res.tempFilePath; // console.log("downloadFile res=>", res)


let newPath = wx.env.USER_DATA_PATH + "/" + filePath.slice(-5);



console.log("newPat=>", newPath)
        wx.getFileSystemManager().rename({
          oldPath: filePath,
          newPath: newPath,
          success(res) {
            console.log(' wx.getFileSystemManager().rename res=>', res)
            wx.openDocument({
              filePath: newPath,
              success(res) {
                console.log('打开文档成功 res=>', res)
                self.closePopupTap();
              },
              fail(err) {
                console.log('打开文档失败 err=>', err)
                wx.showToast({
                  title: '文档打开失败',
                  icon: "none"
                })
              }
            });
          },
          fail(err) {

            console.log(' wx.getFileSystemManager().rename err=>', err)


// ios 命名文件名称失败。。。。

            wx.showToast({
              title: '文件重命名失败',
              icon: "none",
              duration:2500
            });
            wx.openDocument({
              filePath: filePath,
              success(res) {
                console.log('打开文档成功 res=>', res)
                self.closePopupTap();
              },
              fail(err) {
                console.log('打开文档失败 err=>', err)
                wx.showToast({
                  title: '文档打开失败',
                  icon: "none"
                })
              }
            })
          }
        })



想知道这个IOS重命名如何才能成功,这个命名是否成功是否影响到了IOS手机端wx.openDocumen 不知道如何找到文件位置和当前打开无法发送分享文件,安卓端是可以分享的,并重命名找到的。。



回答关注问题邀请回答
收藏

1 个回答

登录 后发表内容