Hi

I've just done some refactoring around consolidating the code to do
with processing multipart/form-data,

but one thing I missed is that CXF definitely supports writing (and
reading) multipart/form-data payloads.

I'm not even sure why I said it didn't.

There is only one restriction to do with writing multipart/form-data
data: if multiple files are submitted then all file-related parts will
be available as siblings (as in your example below), as opposed to
having a single 'parent' part with Content-Type multipart/mixed and
subparts representing individual files as shown at [1].

CXF supports read both formats. I'm not sure what happens if CXF sends
or returns a 'flat' collection of files in multipart/form-data format
with a 3rd party consumer reading it.

Rice, can you experiment please ?

You can just pass an explicit File object to WebClient and set
Content-Type to multipart/form-data.
With the latest update I did you can post a List of Files too.

Alternatively build MultipartBody from as many Attachments as needed,
and when creating Attachments use a constructor accepting
Content-Disposition.

Sergey

[1] http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4.2




On Fri, Mar 11, 2011 at 4:50 PM, Rice Yeh <[email protected]> wrote:
> Hi,
>  How do I compose a mulitpart/form-data with a form field and a file like
> below with cxf?
>
>        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--
>
>
> Regards,
> Rice
>



-- 
Sergey Beryozkin

Application Integration Division of Talend
http://sberyozkin.blogspot.com

Reply via email to