use of org.apache.cxf.jaxrs.ext.multipart.Attachment in project tesb-rt-se by Talend.
the class RESTClient method createMultipartBody.
/**
* Creates MultipartBody. It contains 3 parts, "book1", "book2" and "image".
* These individual parts have their Content-Type set to application/xml,
* application/json and application/octet-stream
*
* MultipartBody will use the Content-Type value of the individual
* part to write its data by delegating to a matching JAX-RS MessageBodyWriter
* provider
*
* @return
* @throws Exception
*/
private MultipartBody createMultipartBody() throws Exception {
List<Attachment> atts = new LinkedList<Attachment>();
atts.add(new Attachment("book1", "application/xml", new Book("JAXB", 1L)));
atts.add(new Attachment("book2", "application/json", new Book("JSON", 2L)));
atts.add(new Attachment("image", "application/octet-stream", getClass().getResourceAsStream("/java.jpg")));
return new MultipartBody(atts, true);
}
Aggregations