alexanoid alexanoid - 1 year ago 70
Java Question

Spring RestController submit file

As a part of a client request - image file must be submitted to my Spring

RestController
endpoint.

Is it possible to use
@RequestParam("file") MultipartFile file
with
RestController
?

If so, could you please show an example.

Answer Source

Yes, it is possible and quite simple:

@RequestMapping("upload")
public void upload(@RequestParam("file") MultipartFile file){
  //Do what you like with the file
}