Я нашел этот пример в руководстве:
https://github. com/OpenFeign/feign-form?tab=readme-ov-file#multipartform-data
Код: Выделить всё
// FormData parameter
@RequestLine("POST /send_photo")
@Headers("Content-Type: multipart/form-data")
void sendPhoto (@Param("is_public") Boolean isPublic, @Param("photo") FormData photo);
Код: Выделить всё
// client method:
@RequestLine("POST /send_photo")
@Headers("Content-Type: multipart/form-data")
void sendPhoto (@Param("photo") FormData photo);
// using above method
var myImageStream = MyClass.class.getResourceAsStream("/test.jpg");
var myImage = FormData.builder()
.fileName("test.jpg")
.contentType("image/jpeg")
.data(myImageStream.readAllBytes())
.build();
client.sendPhoto(true, myImage);
Код: Выделить всё
// client method:
@RequestLine("POST /send_photo")
@Headers("Content-Type: multipart/form-data")
void sendPhoto (@Param("photo") List photo);
// using above method
var myImageStream = MyClass.class.getResourceAsStream("/test.jpg");
var myImage = FormData.builder()
.fileName("test.jpg")
.contentType("image/jpeg")
.data(myImageStream.readAllBytes())
.build();
client.sendPhoto(true, List.of(myImage));
Подробнее здесь: https://stackoverflow.com/questions/790 ... out-spring
Мобильная версия