收藏
回答

下载文件失败,提示 fail url scheme is invalid

框架类型 问题类型 API/组件名称 终端类型 微信版本 基础库版本
小程序 Bug wx.downloadFile 工具 6.6.7 2.2.0


/**
     * 下载文件
     */
    downloadFile: function() {
        wx.showLoading();
        let that = this;
        wx.downloadFile({
            url: that.data.plateInfo.sourceLink,
            success: function (res) {
                console.log('res=',res);
                if (res.statusCode === 200) {
                    var tempFilePath = res.tempFilePath;
                    wx.saveFile({
                        tempFilePath: tempFilePath,
                        success: function(res2) {
                            wx.hideLoading();
                            console.log('res2=',res2);
                            var savedFilePath = res2.savedFilePath;
                            console.log(savedFilePath);
                        },
                        fail: function(err) {
                            console.log('err2=',err);
                            wx.showToast({
                                title: "保存文件失败",
                                icon: 'none',
                                duration: 2500
                            });
                        }
                    });
                } else {
                    wx.showToast({
                        title: "下载文件失败",
                        icon: 'none',
                        duration: 2500
                    });
                }
            },
            fail: function(err) {
                console.log('err1=',err);
                wx.showToast({
                    title: "下载文件失败",
                    icon: 'none',
                    duration: 2500
                });
            }
        });
    }

其中,

that.data.plateInfo.sourceLink = "https://kotdev.oss-cn-shenzhen.aliyuncs.com/201808/07/sns/sns_yknWtsts850807JKJIC5YA.pdf";


点击下载,提示


{errMsg: "downloadFile:fail url scheme is invalid"}


请问怎么回事?

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

1 个回答

登录 后发表内容