【品牌:Xiaomi】【型号:MI MAX 2】
{"statusCode":500,"header":{"Date":"Sun, 08 Oct 2023 03:19:26 GMT","Server":"nginx/1.20.1","Vary":"Origin,Access-Control-Request-Method,Access-Control-Request-Headers","Transfer-Encoding":"chunked","Content-Type":"application/json","Connection":"keep-alive","protocol":"http/1.1"},"data":"{\"timestamp\":\"2023-10-08T03:19:26.544+00:00\",\"status\":500,\"error\":\"Internal Server Error\",\"path\":\"/upload\"}","cookies":[],"errMsg":"uploadFile:ok"}
请具体描述问题出现的流程,并提供能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。
function uploadFile(filepath) {
ui.showLoading('正在上传')
return new Promise((resolve, reject) => {
wx.uploadFile({
filePath: filepath,
name: 'file',
url: app.globalData.url + app.globalData.servicePath + 'file/upload',
header: {
'Content-Type': 'multipart/form-data',
'Authorization': app.token == null ? wx.getStorageSync("token") : app.token,
},
formData: {
method: 'POST'
},
timeout: 10000,
success(res) {
if (res.statusCode == 413) {
ui.showErrorToast('文件过大,请重新上传')
}
var data = JSON.parse(res.data)
if (data.code == 200) {
resolve(data)
}
console.log(logStr, res);
},
fail(err) {
console.log('uploadFile', err);
ui.showToast('上传已超时,请检查网络是否异常')
reject(err)
},
complete() {
ui.hideLoading()
},
})
})
}