イメージをファイルシステムにアップロードします。だから私はを使用しています。また、Advance Rest Client(Chrome)ツールを使用してPOST
マルチパートファイルにアクセスしています。しかし、私はコンテンツタイプを指定しなくてもエラーに直面していますorg.apache.tomcat.util.http.fileupload.FileUploadException:マルチパート境界が見つからなかったため、リクエストが拒否されました。ここで高度なレストクライアント(Chrome)を使用したSpringBootの簡易マルチパートファイルのアップロード
私の残りのコントローラのコード、
@RestController
public class StringController {
@RequestMapping(value="/upload", method=RequestMethod.POST)
public @ResponseBody String singleSave(@RequestParam("file") MultipartFile file){
String fileName = null;
if (!file.isEmpty()) {
try {
fileName = file.getOriginalFilename();
byte[] bytes = file.getBytes();
BufferedOutputStream buffStream =
new BufferedOutputStream(new FileOutputStream(new File("F:/" + fileName)));
buffStream.write(bytes);
buffStream.close();
return "You have successfully uploaded " + fileName;
} catch (Exception e) {
return "You failed to upload " + fileName + ": " + e.getMessage();
}
} else {
return "Unable to upload. File is empty.";
}
}
}
スクリーンショット(残りのクライアントツールを進める)
エラー
{ "timestamp": 1490678908517, "status": 500, "error": "Internal Server Error", "exception": "org.springframework.web.multipart.MultipartException", "message": "Could not parse multipart servlet request; nested exception is java.io.IOException: org.apache.tomcat.util.http.fileupload.FileUploadException: the request was rejected because no multipart boundary was found", "path": "/upload" }
兄弟は働いた。あなたの親切な反応をありがとう。しかし、私はなぜそれが事前にクライアントを休んで動作していない知っているかも – Narendhran