我将jhipster 6.0.1
和ReactJS
用于微服务。
尝试上传文件时出现500错误
{
"type":"https://www.jhipster.tech/problem/problem-with-message",
"title":"Internal Server Error","status":500,
"detail":"java.io.IOException: UT000036: Connection terminated parsing multipart data",
"path":"/error","message":"error.http.500"
}
这是我的JavaScript代码:
uploadFiles = files => {
const formData = new FormData();
for (let i = 0; i < files.length; i++) {
formData.append("files", files[i]);
}
const token = `Bearer ${JSON.parse(
sessionStorage.getItem("jhi-authenticationToken")
)}`;
fetch("/services/filestore/api/file-uploads", {
method: "POST",
headers: new Headers({
"Content-Type": "multipart/form-data",
Accept: "application/json",
Authorization: token
}),
body: formData
})
.then(res => res.json())
.then(data => console.log(JSON.stringify(data)));
};
什么是重要的,当我尝试通过挥杆上传文件时,它可以完美运行,但不能通过curl上传
curl -X POST --header 'Content-Type: multipart/form-data' --header 'Accept: application/json' --header 'Authorization: Bearer asdfasassdfasf' {"type":"formData"} 'http://localhost:8080/services/filestore/api/file-uploads'
地雷代码有什么问题?