- java에서 서버에 파일 upload하는 api
@PostMapping("/upload")
public ResponseEntity<String> uploadModel(@RequestParam("file") MultipartFile file, String version, String feed, String fetch){
try{
String fileName = file.getOriginalFilename();
String insertFileName = fileName.replace(".zip","");
File destFile = new File("/models/"+fileName);
//model 복사
file.transferTo(destFile);
return new ResponseEntity<>("file uploaded successfully", HttpStatus.OK);
}catch(IOException e){
e.printStackTrace();
return new ResponseEntity<>("file upload failed", HttpStatus.INTERNAL_SERVER_ERROR);
}
}