Когда я пытаюсь загрузить файл, я получаю ошибку 500 - PullRequest
0 голосов
/ 17 мая 2019

Я использую 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)));
};

Что важно, когда я пытаюсь загрузить файл через swagger, он отлично работает, но не работает через 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'

Что не так в моем коде?

...