1***@qq.com
1***@qq.com
  • 发布:2025-02-20 11:38
  • 更新:2025-02-21 11:53
  • 阅读:40

【报Bug】uniapp 打包的安卓app使用uni.uploadFile有时候成功有时候失败并报错uploadFile:fail undefined

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Windows

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

HBuilderX类型: 正式

HBuilderX版本号: 4.36

手机系统: Android

手机系统版本号: Android 15

手机厂商: vivo

手机机型: iqoo neo9spro+

页面类型: vue

vue版本: vue2

打包方式: 云端

项目创建方式: HBuilderX

示例代码:

uni.uploadFile({
header: {
'token': api.__CFG.TOKEN || '',
'content-type': 'multipart/form-data'
},
url: this.Setting.url,
filePath: data.fullPath,
name: 'file',
formData: formData,
success: res2 => {
console.log('888',res2)
// fs.unlinkSync(tempPath)
if (res2.statusCode === 200) {
const r_data = JSON.parse(res2.data)
if (r_data.error == 0) {
this.currentChunk++
if (this.currentChunk < this.chunks) {
this.loadNext()
} else {
r_data.md5value = datas.md5value
console.log('formData',datas)
this.callback(r_data)
}
} else {
this.callback(false)
}
} else {
this.callback(false)
}
},
fail: err => {
console.log('999',err)
this.callback(false)
}
})

操作步骤:

按我上述操作

预期结果:

能正常返回走进success而不是走到fail去

实际结果:

大概率会走到fail去,但有时候又进success正常请求

bug描述:

目前只测试到安卓app中使用uni.uploadFile大部分会走fail 然后打印出来是uploadFile:fail undefined,但是有时候又可以正常上传,不知道怎么回事

2025-02-20 11:38 负责人:DCloud_Android_THB 分享
已邀请:
DCloud_App_Array

DCloud_App_Array

请提供简化的复现此问题的示例项目,包括要上传的文件。

要回复问题请先登录注册