在 FileUploadController控制器中修改handleFileUploadVideo方法,在上传文件时调用/video/add restful服务接口
@PostMapping("/uploadVideo")
@ResponseBody
public String handleFileUploadVideo(@RequestParam("file") MultipartFile file,
RedirectAttributes redirectAttributes) {
System.out.print("handleFileUploadVideo>>>>>>>>>>>");
storageService.store(file);
//String postUrl = "http://localhost:8080/addVideo";
String postUrl = "http://localhost:8080/video/add";
MultiValueMap request =new LinkedMultiValueMap();
String filename = StringUtils.cleanPath(file.getOriginalFilename());
request.add("fileName",filename);
request.add("filePath","/img/"+filename);
request.add("author","fantasy");
RestTemplate restTemplate = new RestTemplate();
ResponseEntity rst = restTemplate.postForEntity(postUrl, request, String.class);
System.out.println("Rest result:"+rst);
return file.getOriginalFilename();
}
@PostMapping("/uploadVideo")
@ResponseBody
public String handleFileUploadVideo(@RequestParam("file") MultipartFile file,
RedirectAttributes redirectAttributes) {
System.out.print("handleFileUploadVideo>>>>>>>>>>>");
storageService.store(file);
//String postUrl = "http://localhost:8080/addVideo";
String postUrl = "http://localhost:8080/video/add";
MultiValueMap request =new LinkedMultiValueMap();
String filename = StringUtils.cleanPath(file.getOriginalFilename());
request.add("fileName",filename);
request.add("filePath","/img/"+filename);
request.add("author","fantasy");
RestTemplate restTemplate = new RestTemplate();
ResponseEntity rst = restTemplate.postForEntity(postUrl, request, String.class);
System.out.println("Rest result:"+rst);
return file.getOriginalFilename();
}