alexanoid alexanoid - 5 months ago 11
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

Yes, it is possible and quite simple:

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