I need to save a Image into local folder and download it after using Spring Boot in both cases. On my DB I save only the name of the file.
I save the image with this:
@PostMapping("/saveimage")
public ResponseEntity<Usuario> insertProduct(@RequestPart("body") String body,
@RequestPart("imagen") MultipartFile imagen) {
//......
}
But now, I need to recover it with a get request to work on other app.
How could I recover this? Only with URL I can't because both applications are on different servers so I need to do it with GetRequest.
I've tried this:
@GetMapping("/getimage/{path}")
ResponseEntity<File> imagen(@PathVariable String path) {
File file = new File(this.uploadingDir + path);
return new ResponseEntity<File>(file, HttpStatus.OK);
}
But it doesn't work properly, I get the full path not the file.