@@ -80,18 +80,37 @@ interface SomeApi {
8080
8181 ...
8282
83+ // File parameter
8384 @RequestLine (" POST /send_photo" )
8485 @Headers (" Content-Type: multipart/form-data" )
8586 void sendPhoto (@Param (" is_public" ) Boolean isPublic , @Param (" photo" ) File photo );
8687
88+ // byte[] parameter
89+ @RequestLine (" POST /send_photo" )
90+ @Headers (" Content-Type: multipart/form-data" )
91+ void sendPhoto (@Param (" is_public" ) Boolean isPublic , @Param (" photo" ) byte [] photo );
92+
93+ // FormData parameter
94+ @RequestLine (" POST /send_photo" )
95+ @Headers (" Content-Type: multipart/form-data" )
96+ void sendPhoto (@Param (" is_public" ) Boolean isPublic , @Param (" photo" ) FormData photo );
8797 ...
8898
8999}
90100```
91101
92- In example above, we send file in parameter named ** photo** with additional field in form ** is_public ** .
102+ In the example above, the ` sendPhoto ` method uses the ` photo ` parameter using three different supported types .
93103
94- > ** IMPORTANT:** You can specify your files in API method by declaring type ** File** or ** byte[ ] ** .
104+ * ` File ` will use the File's extension to detect the ` Content-Type ` .
105+ * ` byte[] ` will use ` application/octet-stream ` as ` Content-Type ` .
106+ * ` FormData ` will use the ` FormData ` 's ` Content-Type ` .
107+
108+ ` FormData ` is custom object that wraps a ` byte[] ` and defines a ` Content-Type ` like this:
109+
110+ ``` java
111+ FormData formData = new FormData (" image/png" , myDataAsByteArray);
112+ someApi. sendPhoto(true , formData);
113+ ```
95114
96115### Spring MultipartFile and Spring Cloud Netflix @FeignClient support
97116
0 commit comments