小程序下文文件 后缀为unknown ?
发布于 7 年前 作者 qianwei 11357 次浏览 来自 问答

代码如下 下载https的文件 下载后 后缀为unknown 请大牛们给解答下 提供下解决方法 感谢! 为什么会出现这个问题

wx.downloadFile({

      // url: options.fjPath,

      url: ‘https://**************/20200601/1590980306529094479.pdf’,

      header: {

        ‘content-type’: ‘application/pdf’

      },

      success: function (res) {

        wx.saveFile({

          tempFilePath: res.tempFilePath,

          success: function (res2) {

            wx.openDocument({

              filePath: res2.savedFilePath,

              // fileType:‘pdf’,

              success: function (res) {

                that.setData({

                  tsMsg: ‘已完成’

                })

                wx.navigateBack({

                  delta: 0,

                })

              },

              fail: function (e) {

                console.log(‘打开失败’, e)

              },

              complete: function (e) {

                console.log(e)

              }

            });

          },

          fail: function (err) {

            console.log(‘保存失败:’, err)

          }

        });

      },

      fail: function (err) {

        console.log(‘下载失败:’, err);

      },

    });

1 回复

这个设置了吗?

回到顶部