const aliyunFileKey = params.key; const aliyunServerURL = env.uploadImageUrl; const accessid = env.OSSAccessKeyId; const policyBase64 = getPolicyBase64(); const signature = getSignature(policyBase64); console.log('aliyunFileKey=', aliyunFileKey); // console.log('aliyunServerURL', aliyunServerURL); wx.uploadFile({ url: aliyunServerURL, filePath: params.filePath, name: 'file', formData: { 'key': aliyunFileKey, 'policy': policyBase64, 'OSSAccessKeyId': accessid, 'signature': signature, 'success_action_status': '200', }, success: function (res) { if (res.statusCode != 200) { if(params.fail){ params.fail(res) } return; } if(params.success){ params.success(aliyunFileKey); } }, fail: function (err) { err.wxaddinfo = aliyunServerURL; if (params.fail) { params.fail(err) } }, })
wx.uploadFile上传文件失败报错,什么原因?最近使用wx.uploadFile直传文件到oss经常失败,后台获取报错信息有以下几种,请看看什么原因 1、 {\"errMsg\":\"uploadFile:fail socket timeout\",\"wxaddinfo\":\"https://*****.oss-cn-shanghai.aliyuncs.com\"} 2、{\"errMsg\":\"uploadFile:fail upload fail:-103:net::ERR_CONNECTION_ABORTED\",\"wxaddinfo\":\"https://*****.oss-cn-shanghai.aliyuncs.com\"} 3、"{\"errMsg\":\"uploadFile:fail interrupted\",\"wxaddinfo\":\"https://*****.oss-cn-shanghai.aliyuncs.com\"}" 4、"{\"errMsg\":\"uploadFile:fail upload fail:-101:net::ERR_CONNECTION_RESET\",\"wxaddinfo\":\"https://*****.oss-cn-shanghai.aliyuncs.com\"}" 5、"{\"errMsg\":\"uploadFile:fail 请求超时。\",\"wxaddinfo\":\"https://*****.oss-cn-shanghai.aliyuncs.com\"}"
2022-02-15