收藏
回答

wx.downloadFile 下载文件后缀名 为 unknown

框架类型 问题类型 API/组件名称 终端类型 操作系统 微信版本 基础库版本
小程序 Bug wx.downloadFile 微信iOS客户端 Android 6.6.7 2.1.2


    return new Promise(function(resolve, reject) {

        wx.downloadFile({

            url: conf.url + `${url}${data ? "?" + JSON.stringify(data) : ""}`,

            header: {

                'Cookie': 'JSESSIONID=' + getApp().globalData.jsessionid

            },

            success: function(res) {

                if (res.statusCode === 200) {

                    console.log(res);

                    wx.saveFile({

                    tempFilePath: res.tempFilePath,

                    success(res){

                        console.log(res);

                        wx.openDocument({

                            filePath: res.savedFilePath,

                            success: function (res) {

                                console.log('打开文档成功')

                            },

                            fail(res){

                                console.log(res);

                            }

                       })

                    },

                    fail(res){

                        console.log("下载失败")

                    }

                })

               resolve(res)

            } else {

                reject(res)

            }

            },

            fail: function(res) {

                reject(res);

            },

            complete: function(res) {

                if (complete) complete(res)

            },

        })

    })


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

3 个回答

登录 后发表内容