微信小程序 saveVideoToPhotosAlbum:fail invalid file type

小程序文件下载时候报错saveVideoToPhotosAlbum:fail invalid file type 因为类型不正确需要指定一下下载的类型。 wx.downloadFile({
url: s,
header: i.buildHeader(n),
success: function(i) {
200 === i.statusCode ? (t.setData({
downloadVideoBtnText: “保存中”
}), t.setData({
tempVideoFilePath: i.tempFilePath
}), console.log(i), wx.saveVideoToPhotosAlbum({
filePath: i.tempFilePath,
success: function(e) {
if (console.log(e), t.setData({
showDownloadProgressModel: !1
}), -1 != t.data.adBannerType && 1 == t.data.showAlertAD) t.setData({

                        downloadVideoDisabled: !1,
                        showModal: !0
                    }); else {
                        var a = "成功保存到手机,保存位置请看屏幕提示";
                        "ios" == o.globalData.systemInfo.platform && (a = "成功保存到手机相册"), wx.showModal({
                            showCancel: !1,
                            title: "保存成功",
                            content: a
                        });
                    }
                    console.log(e.errMsg);
                },
                fail: function(e) {
                    console.log(e), wx.showToast({
                        title: "保存失败,请允许保存至相册"
                    }), t.setData({
                        showDownloadProgressModel: !1,
                       
                        downloadVideoDisabled: !1
                    });
                }
            })) : (wx.reportAnalytics("download_fail", {
                link: s,
                source_link: t.data.parseVideoUrl
            }), 1 == a ? (console.log("重试"), t.setData({
                downloadVideoBtnText: "正在重试...",
                downloadVideoDisabled: !0
            }), t.downloadVideo(e, a + 1)) : (t.setData({
                showDownloadProgressModel: !1
            }), wx.showModal({
                title: "下载失败",
                content: t.data.downloadErrorMsg
            })));
        },
        fail: function(o) {
            o.errMsg, 1 == a ? (console.log("重试"), t.setData({
                downloadVideoBtnText: "正在重试...",
                downloadVideoDisabled: !0
            }), t.downloadVideo(e, a + 1)) : (t.setData({
                showDownloadProgressModel: !1
            }), wx.showModal({
                title: "下载失败",
                content: t.data.downloadErrorMsg
            }));
        },
发布了55 篇原创文章 · 获赞 2 · 访问量 6万+

猜你喜欢

转载自blog.csdn.net/wqs15192095633/article/details/100581026