uni-app将uni.downloadFile媒体下载保存到相册

作者: JONE 分类: PHPer 发布时间: 2020-07-26 22:20

原链接 https://www.dungei.com/7882.html

down_video() {

const downloadTask = uni.downloadFile({
url: ‘http://v6-dy-x.ixigua.com/b8bd972393bdcff3ed403bed237fa6e9/5f1d9be3/video/tos/cn/tos-cn-ve-15/ac7bb2a56a10475b830f0cd3b9b94875/?a=1128&br=6516&bt=2172&cr=0&cs=0&dr=0&ds=3&er=&l=202007262206000100140460210D3C5264&lr=&mime_type=video_mp4&qs=0&rc=ajx1dXc0dmQ8djMzZmkzM0ApZzc7ZDdpM2QzN2RkPGY5NGc2MHEvLWoubmFfLS1iLS9zczItM18xLzAwLzIuL2AuMWA6Yw%3D%3D&vl=&vr=’,
success: (res) => {
if (res.statusCode === 200) {
uni.showToast({
title: “视频连接正确”,
icon: “none”
});
uni.saveImageToPhotosAlbum({
filePath: res.tempFilePath,
success: function() {
uni.showToast({
title: “保存成功”,
icon: “none”
});
},
fail: function() {
uni.showToast({
title: “保存失败,请稍后重试”,
icon: “none”
});
}
});
}
}