I'm using Spring MVC as a rest controller and I've integrated Swagger-ui with my controller using Springfox. I'd like to have a method that is able to upload a file via the Swagger-ui interface. I only need two parameters, a long acting for an object id and the file to be uploaded.
Код: Выделить всё
@RestController
public class controller{
@RequestMapping(value="/upload", method=RequestMethod.POST)
public void uploadFile(@RequestParam Long id,
@RequestParam MultipartFile file){
//do some stuff
}
}
Код: Выделить всё
@RestController
public class Controller{
@RequestMapping(value="/upload", method=RequestMethod.POST)
public void uploadFile(@RequestParam Long id,
@RequestPart File file){
//do some stuff
}
}
Код: Выделить всё
@RestController
public class Controller{
@RequestMapping(value="/upload", method=RequestMethod.POST)
public void uploadFile(@RequestPart String metaData,
@RequestPart MultipartFile file){
//do some stuff
}
}
Источник: https://stackoverflow.com/questions/314 ... swagger-ui