users@jersey.java.net

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

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Mon, 23 Mar 2009 08:41:17 +0100

Hi Imran,

Great! In addition to the issues for bugs could you create an issue
for the proposed form sample and attach the files you attached in this
email. That way it will be easier to manage.

Thanks,
Paul

On Mar 23, 2009, at 8:31 AM, Imran M Yousuf wrote:

>> <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
> <0001-Fix-content-disposition-construction-with-null-
> name.patch><0002-Add-convenience-form-body-part-extension-for-
> java
> .io
> .patch
> >---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net