users@jersey.java.net

[RFC] Patches regarding file body part - Re: [Jersey] Uploading files using Jersey client

From: Imran M Yousuf <imran_at_smartitengineering.com>
Date: Mon, 23 Mar 2009 13:31:44 +0600

> <snip />
>>>>
>>>> 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.
>>>
>>> The only thing that I wanted to avoid is creating disposition
>>> manually. So basically what I would like to see is some like -
>>>
>>> new FileDataBodyPart(String formParamName, java.io.File attachment,
>>> MediaType mediaType);
>>> new FileDataBodyPart(String formParamName, java.io.File attachment);
>>> //Will add media type from file name
>>>
>>
>> OK. Can you please log an issue?
>>
>
> I can log the issue and also contribute to it since it will be fairly
> straight forward implementation, I will work on it this weelend and
> will submit a patch on Monday, if all goes well.
>

I have tried working on it and completed the work attached in the
patch. Please let me know what you think. I will now create the issues
we discussed in the other thread.

Thank you,

-- 
Imran M Yousuf
Entrepreneur & Software Engineer
Smart IT Engineering
Dhaka, Bangladesh
Email: imran_at_smartitengineering.com
Blog: http://imyousuf-tech.blogs.smartitengineering.com/
Mobile: +880-1711402557