I am trying to send a multipart form data using web client

Here is the code :

                WebClient client =
WebClient.create("http://localhost:8080";);
                client.accept(MediaType.APPLICATION_JSON);
                client.type(MediaType.MULTIPART_FORM_DATA_TYPE);
                ContentDisposition cd1 = new ContentDisposition("form-data;
name=\"file\";filename=\"test.txt\"");

                ContentDisposition cd2 = new
ContentDisposition("form-data;name=\"textfield\"");
                List<Attachment>  atts = new LinkedList<Attachment>();
                atts.add(new Attachment("textfield", new
ByteArrayInputStream("my_textfield_value".getBytes()), cd2));
                atts.add(new Attachment("file", new FileInputStream(new
File("/home/pratyush/test.txt")), cd1));
                MultipartBody body = new MultipartBody(atts);
                client.post(body, String.class);


Here is the request at server side :

--uuid:87d4e978-49d5-418b-a4d4-7f29b91cd5e5
Content-Type: application/octet-stream
Content-Transfer-Encoding: binary
Content-ID: <textfield>
Content-Disposition: form-data;name="textfield"

my_textfield_value
--uuid:87d4e978-49d5-418b-a4d4-7f29b91cd5e5
Content-Type: application/octet-stream
Content-Transfer-Encoding: binary
Content-ID: <file>
content-disposition: null

test

--uuid:87d4e978-49d5-418b-a4d4-7f29b91cd5e5--
--------------------------------------




I can't figure out why is second context-disposition null ? I am using
cxf-rt-frontend-jaxrs version 2.5.2.


--
View this message in context: 
http://cxf.547215.n5.nabble.com/Content-Disposition-is-null-in-multipart-form-data-request-tp5512412p5512412.html
Sent from the cxf-user mailing list archive at Nabble.com.

Reply via email to