wuyi
wuyi
  • 发布:2022-07-06 20:20
  • 更新:2023-03-01 15:32
  • 阅读:657

【报Bug】saveFile保存文件失败

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: win10

HBuilderX类型: 正式

HBuilderX版本号: 3.4.18

手机系统: Android

手机系统版本号: Android 10

手机机型: 安卓

页面类型: vue

vue版本: vue2

打包方式: 云端

项目创建方式: HBuilderX

示例代码:

//保存文件到本地
saveFileDownloadCs(url) {
url = "http://192.168.252.30:8080/profile/upload/video/2022/06/07/f5c350d1-99e9-4262-a1bc-5c28f55b7732.mp4"
uni.showToast({
title: "进入文件保存",
icon: 'none',
duration: 3000
})
console.log("测试中" + url)
let that = this
uni.downloadFile({
url: url,
success: res => {
if (res.statusCode === 200) { // saveImageToPhotosAlbum saveVideoToPhotosAlbum
uni.saveFile({
tempFilePath: res.tempFilePath, //临时路径
success: function(saveFileRes) {
uni.showToast({
title: "正在保存文件" + saveFileRes.savedFilePath,
icon: 'none',
duration: 2000
})
},
fail(res2) {
uni.showToast({
title: "报错失败" + res2,
icon: 'none',
duration: 2000
})
},
complete(res3) {
uni.showToast({
title: "保存完成" + res3,
icon: 'none',
duration: 2000
})
}
})
}
else {
uni.showToast({
title: "下载失败",
icon: 'none',
duration: 2000
})
}
},
complete: () => {

                            }  
                        })  
                },

操作步骤:

app打包后设置开机自启动

预期结果:

开机自启动能正常保存文件

实际结果:

开机自启动无法保存文件

bug描述:

安卓机器上设置app开机自启动,app启动后调用uni.saveFile保存文件,返回保存成功但是文件夹里面没有任何文件,然后退出手动点击启动app就可以下载文件成功。下面是方法

2022-07-06 20:20 负责人:无 分享
已邀请:
星星不怕黑

星星不怕黑

自启动是由很多问题的,系统还有些东西没准备好,应用就启动了,这个问题我以前遇到过类似的

要回复问题请先登录注册