我在使用nodejs上传文件时遇到问题,这是代码:
failedUrl = settings.getApiUrl() + '/api/organisationupload/' + uploadId + '/tenant/' + tenantId + '/markAsFailed';
var boundary = "----7da24f2e50046";
var data = "";
data += "--" + boundary + "\r\n";
data += "Content-Disposition: form-data; name=\"file\"; filename=\"" + "FailedData.csv" + "\"\r\n";
data += "Content-Type:application/vnd.ms-excel\r\n\r\n";
//data += "Content-Type:text/plain\r\n\r\n";
data += failedRowsData + "\r\n\r\n";
data += boundary + "--";
context.log(data);
axios({
method: 'post',
headers: {
'Content-Type': "multipart/form-data; boundary=" + boundary,
'Content-Length': Buffer.byteLength(data)
},
data: data,
url: failedUrl,
//body: data
})
然后,.Net API部分将出现异常,这是代码:
Task.Run(async () => { await content.ReadAsMultipartAsync(provider); }).GetAwaiter().GetResult();
它显示:
mscorlib.dll中发生了'System.IO.IOException'类型的异常,但未在用户代码中处理
其他信息:MIME多部分流的意外结尾。 MIME分段消息不完整。
我猜axios部分不正确。有人有新想法吗?