Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.



Span
stylefont-size:2em;font-weight:bold
JAX-RS : Support for Multiparts

 


Table of Contents

Reading attachments

...

Code Block
java
java
WebClient client = WebClient.create("http://books");t
client.type("multipart/form-data");
ContentDisposition cd = new ContentDisposition("attachment;filename=image.jpg");
Attachment att = new Attachment("root", imageInputStream, cd);
client.post(new MultipartBody(att));

// or just post the attachment if it's a single part request only
client.post(att);

// or just use a file
client.post(getClass().getResource("image.png").getFile());

...

Note that once a request has more than two parts then one needs to start using @Mutipart@Multipart, the values can refer to either ContentId header or to ContentDisposition/name. Note that at the moment using @Multipart is preferred to using @FormParam unless a plain name/value submission is dealt with. The reason is that @Multipart can also specify an expected media type of the individual part and thus act similarly to a @Consume annotation.

...