My jersey vision is 1.1.4.1.Sorry for missing that.
michael_cheng wrote:
>
> Hi Paul,
> Thanks for your fast response.
> I read the jersey start and did not find some imformation about
> jersey-client-components configuration.Maybe I missed some details about
> that.
> And which format should the file "jersey-client-components" be?XML or .mf?
> Or you can give me a example about that.
> Thanks in advance.
>
> Best Regards,
> Michael
>
> Paul Sandoz wrote:
>>
>> Hi,
>>
>> What version of Jersey are you using?
>>
>> Do you see output like:
>>
>> INFO: Adding the following classes declared in
>> META-INF/services/jersey-client-components to the client configuration:
>> class com.sun.jersey.multipart.impl.MultiPartConfigProvider
>> class com.sun.jersey.multipart.impl.MultiPartReader
>> class com.sun.jersey.multipart.impl.MultiPartWriter
>>
>> in the logs?
>>
>> The behavior that you observe indicates that multipart MIME parsing
>> has not occurred and instead you are getting complete message (as you
>> indicate).
>>
>> Note that the name "file" in @FormDataParam("file") is incorrect, you
>> need to use the same value as that in the name attribute on the form
>> input element, in this case "picture". However, i do not think that
>> will solve your problem.
>>
>> Paul.
>>
>> On Dec 3, 2009, at 3:49 PM, michael_cheng wrote:
>>
>>>
>>> Hi,
>>> It's about file upload when my project using jax-rs.I followed the
>>> code
>>> which the @FormDataParam API mentioned.
>>> Please help me about this issue.
>>>
>>> My client code:
>>> <form action="http://localhost:8080/testImage" method="post"
>>> enctype="multipart/form-data">
>>> <input type="file" name="picture" />
>>> <input type="submit" value="Send" />
>>> </form>
>>>
>>> My server code:
>>> @POST
>>> @Path("testImage")
>>> @Consumes(MediaType.MULTIPART_FORM_DATA)
>>> public void getImage(
>>> @FormDataParam("file") InputStream in) throws IOException{
>>> OutputStream os = new FileOutputStream(new
>>> File("D:\\good.jpg"));
>>> byte[] b = new byte[in.available()];
>>> int i = 0;
>>> while ((i = in.read(b)) >0) {
>>> os.write(b, 0, i);
>>> }
>>> os.flush();
>>> os.close();
>>> in.close();
>>> }
>>>
>>> When i upload a picture,the file "D:\\good.png" will show,and the
>>> fileSize
>>> is as the same .But I can not see the image when I open it.
>>> When debuging the program,I noticed that the InputStream contains
>>> both the
>>> file itself and the file description.Just
>>> like"----------789652236442--Content Type=jpg/
>>> image........xxxxxxxxxxxx(file
>>> itself)----78965222--".
>>> And my question is how can I just get the file itself in InputStream?
>>> Or I
>>> missed something?
>>> I will so appreciated if getting your help.Thanks.
>>> --
>>> View this message in context:
>>> http://n2.nabble.com/Problem-about-file-upload-when-using-FormDataParam-tp4106463p4106463.html
>>> Sent from the Jersey mailing list archive at Nabble.com.
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>
>>
>>
>
>
--
View this message in context: http://n2.nabble.com/Problem-about-file-upload-when-using-FormDataParam-tp4106463p4110324.html
Sent from the Jersey mailing list archive at Nabble.com.