It seems like I ask more questions than anyone else on the list (thanks
for the help BTW :), and maybe someday I can fix that, but... I have
another question. :)
I'm trying to figure out how to do a submit with a file upload. The
scenario is basically identical to an HTML form submission with a file
input (i.e, I have several text fields that I need to POST along with an
arbitrary number of files). Using the Jersey 1.x client, I did
something like this (from a unit test, fwiw):
FormDataMultiPart form = new FormDataMultiPart();
for (Map.Entry<String, Object> entry : payload.entrySet()) {
if ((entry.getValue() instanceof File)) {
form.getBodyParts().add((new
FileDataBodyPart(entry.getKey(), (File)entry.getValue())));
} else {
form.field(entry.getKey(), entry.getValue(),
MediaType.TEXT_PLAIN_TYPE);
}
}
Right or wrong, it worked. :) I've been digging through the Jersey
source, tests, etc all day and haven't found the 2.0 analog. Is this
supported yet, or am I just missing it?
Thanks again! :)
--
Jason Lee
Senior Member of Technical Staff
GlassFish Team
Oracle Corporation
Phone +1 405-216-3193
Blog http://blogs.steeplesoft.com