On Mar 19, 2009, at 11:20 AM, Imran M Yousuf wrote:
> File file = new File("src/test/resources/Splash-
> resized.jpg");
> MediaType imageType = new MediaType("image", "jpeg");
> FormDataMultiPart part = new FormDataMultiPart();
> FormDataMultiPart bodyPart = part.field("file", file,
> imageType);
> resource.type(MediaType.MULTIPART_FORM_DATA_TYPE).post(
> part);
Note you can already do the above as follows:
FormDataMultiPart multiPart = new FormDataMultiPart().
field(
"file",
new File("src/test/resources/Splash-resized.jpg"),
MediaType.valueOf("image/jpg")).
build();
resource.type(MediaType.MULTIPART_FORM_DATA_TYPE).post(multiPart);
I have just committed the following to the trunk so you can do:
FormDataMultiPart multiPart = new FormDataMultiPart().
field(
FormDataContentDisposition.name("file").fileName("userfile").build(),
new File("src/test/resources/Splash-resized.jpg"),
MediaType.valueOf("image/jpg")).
build();
I might tweak the builder pattern of FormDataContentDisposition
because it is possible to convert one of the other builder methods in
to a terminated builder method, but the principle will remain the same.
Paul.