users@jersey.java.net

Re: [Jersey] Uploading files using Jersey client

From: Naresh <bsnaresh_at_sun.com>
Date: Thu, 19 Mar 2009 14:53:08 +0530

Imran M Yousuf wrote:
> On Thu, Mar 19, 2009 at 12:17 PM, Naresh <bsnaresh_at_sun.com> wrote:
>
>> Hi Imran,
>>
>> please check the [simple-servlet] sample. It has the code sample for
>> submitting a form.
>>
>> [simple-servlet]
>> http://download.java.net/maven/2/com/sun/jersey/samples/simple-servlet/1.0.3-SNAPSHOT/simple-servlet-1.0.3-SNAPSHOT-project.zip
>>
>
> Thanks. Any idea how I could add an attachment to the Form?
>
You can use the HTML file control for uploading files, and @FormParam
annotation for accessing the file.
The following is a sample code:

@POST
@Path("form")
@Produces("text/plain")
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
public String getFileContents(@FormParam ("inputfile") InputStream
fileStream) {
....
}

HTH,
Naresh
>
>> Thanks,
>> Naresh
>>
>> Imran M Yousuf wrote:
>>
>>> Hi,
>>>
>>> Can someone please help me find code sample for submitting a form
>>> (preferably includes a file attachment) using Jersey Client API?
>>>
>>> Thank you,
>>>
>>>
>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>
>>
>>
>
>
>
>