m***@163.com
m***@163.com
  • 发布:2024-08-29 03:21
  • 更新:2024-08-29 03:21
  • 阅读:48

【报Bug】 uni.downloadFile下载文件报错,status=400,小文件正常下载

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Windows

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

HBuilderX类型: 正式

HBuilderX版本号: 4.24

手机系统: Android

手机系统版本号: Android 12

手机厂商: 华为

手机机型: mate40pro

页面类型: vue

vue版本: vue2

打包方式: 云端

项目创建方式: HBuilderX

示例代码:

test(){
console.log('测试下载文件');
let that = this;
const downloadTask = uni.downloadFile({
// url: 'https://yxdj-res.oss-cn-shenzhen.aliyuncs.com/redaudio.mp3', //下载地址
url: 'https://yxdj-res.oss-cn-shenzhen.aliyuncs.com/msdj2024.apk',
success: (res) => {
console.log('success:'+JSON.stringify(res));
if (res.statusCode === 200) {
console.log('下载成功');
}
},fail: (error) => {
console.log('error:'+JSON.stringify(error));
}
});

                    downloadTask.onProgressUpdate((res) => {  
                        console.log('下载进度' + res.progress);  
                        console.log('已经下载的数据长度' + res.totalBytesWritten);  
                        console.log('预期需要下载的数据总长度' + res.totalBytesExpectedToWrite);  

                        // 满足测试条件,取消下载任务。  
                        if (res.progress > 50) {  
                            // downloadTask.abort();  
                        }  
                    });  

                }

操作步骤:

按上面代码跑在手机上就报错,但是换个小的文件能下载

预期结果:

正常下载

实际结果:

{"tempFilePath":"_doc/uniapp_temp_1724872260530/download/","statusCode":400,"errMsg":"downloadFile:ok"}

bug描述:

使用你们官方的案例 去下载文件,小文件可以下载下来70mb的安装包下不下来
报错提示:{"tempFilePath":"_doc/uniapp_temp_1724862364754/download/","statusCode":400,"errMsg":"downloadFile:ok"}

2024-08-29 03:21 负责人:无 分享
已邀请:

要回复问题请先登录注册