users@jersey.java.net

How to use multipart/form-data

From: Max Scheffler <max_scheffler_at_web.de>
Date: Thu, 12 Jun 2008 15:56:35 +0200

Hi,

i want to create an image resource by uploading an image and setting
some informations for this image.

The following is a possible POST body:

Content-type: multipart/form-data, boundary=AaB03x

--AaB03x
content-disposition: form-data; name="field1"

Joe Blow
--AaB03x
content-disposition: form-data; name="pics"; filename="file1.txt"
Content-Type: text/plain

... contents of file1.txt ...
--AaB03x--

I tried to use the following code:

@POST
public Response createGraphic ( @FormParam( "field1" ) String name,
@FormParam( "pics" ) Object object ) {
   ...
}

But this approach didn't work fine.

How can I fetch the parameters (in this example: field1) and the file?

Greetings
        Max