Загрузка многочастного файла с использованием Springfox и Swagger-uiJAVA

Программисты JAVA общаются здесь
Ответить Пред. темаСлед. тема
Гость
 Загрузка многочастного файла с использованием Springfox и Swagger-ui

Сообщение Гость »


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
}
}
I've tried almost everything and I can't get a file upload button to appear. However, if I do:

Код: Выделить всё

@RestController
public class Controller{
@RequestMapping(value="/upload", method=RequestMethod.POST)
public void uploadFile(@RequestParam Long id,
@RequestPart File file){
//do some stuff
}
}
The file upload button appears, but it always throws http code 415 when trying to upload a file. Besides, I need the input to be a MultipartFile, not a regular File. Even if I use the @RequestPart annotation with Multipart File, the choose file to upload button does not appear. How can I get this to work???? Even:

Код: Выделить всё

@RestController
public class Controller{
@RequestMapping(value="/upload", method=RequestMethod.POST)
public void uploadFile(@RequestPart String metaData,
@RequestPart MultipartFile file){
//do some stuff
}
}
Won't work. If someone could give a walkthrough of how to get this button to appear for MultipartFile? I'd be forever grateful.


Источник: https://stackoverflow.com/questions/314 ... swagger-ui
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «JAVA»