springfox-demos icon indicating copy to clipboard operation
springfox-demos copied to clipboard

Swagger UI - POST a multipartfile

Open antxa opened this issue 9 years ago • 0 comments

Hi all, I've implemented a REST API in Java and one of the POST request accepts a file sent in the body. Everything works OK if I call using this curl: curl -F "[email protected]" localhost:8080/index

The problem is that I'm not able to get the same curl through swagger-ui. This is my snippet code (following the springfox-demos):

 @RequestMapping(value = "/index", method = RequestMethod.POST, consumes={ MediaType.MULTIPART_FORM_DATA_VALUE })
     public ResultIndex index(@RequestPart MultipartFile file)

And this produces the following curl on the swagger-ui: curl -X POST --header 'Content-Type: multipart/form-data' --header 'Accept: */*' {"type":"formData"} 'http://localhost:8080/index'

What should I change/add in my code? Thanks!

antxa avatar Feb 01 '17 16:02 antxa