Hi Vlad,

I'm not 100% positive, but I think you can use the Multipart/Attachment
APIs on the client to send the request.  Here is an example of the
Multipart APIs:
https://github.com/apache/cxf/blob/master/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/ext/multipart/MultipartBodyTest.java

So, if I understand it correctly, then you should be able able to send the
request like this:

List<Attachment> atts = new ArrayList<>();

atts.add(createAttachment("owners", pathToOwnersFile));

atts.add(createAttachment("files", pathToBooksFile)));

MultipartBody b = new MultipartBody(atts);

Client client = ClientBuilder.newClient();

Response r = client.target(myURL).request().post(b);


Hope this helps,

Andy

On Fri, Jun 8, 2018 at 11:43 AM vlad.balan <vlad.ba...@gmail.com> wrote:

> Hello
>
> and thanks whoevers reads the question.
>
>
> In the CXF doc here
>
> http://cxf.apache.org/docs/jax-rs-multiparts.html
> <http://cxf.apache.org/docs/jax-rs-multiparts.html>
>
> it says:
>
> "
>
> Finally, multipart/form-data requests with multiple files (file uploads)
> can
> be supported too. For example, this request can be handled by a method with
> the signature like :
>
> @POST
> @Path("/books/filesform")
> @Produces("text/xml")
> @Consumes("multipart/form-data")
> public Response addBookFilesForm(@Multipart("owner") String name,
>                                  @Multipart("files") List<Book> books) {}
>
> "
>
>
>
> But how to generate that request from the java client side?
>
> This is the request content:
>
>
> --bqJky99mlBWa-ZuqjC53mG6EzbmlxB
> Content-Disposition: form-data; name="owner"
> Content-Type: text/plain
>
> Larry
> --bqJky99mlBWa-ZuqjC53mG6EzbmlxB
> Content-Disposition: form-data; name="files"
> Content-Type: multipart/mixed; boundary=_Part_4_701508.1145579811786
>
> --_Part_4_701508.1145579811786
> Content-Disposition: form-data; name="book1"
> Content-Type: application/json; charset=US-ASCII
> Content-Transfer-Encoding: 8bit
>
> {"Book":{"name":"CXF in Action - 1","id":123}}
> --_Part_4_701508.1145579811786
> Content-Disposition: form-data; name="book2"
> Content-Type: application/json; charset=US-ASCII
> Content-Transfer-Encoding: 8bit
>
> {"Book":{"name":"CXF in Action - 2%","id":124}}
> --_Part_4_701508.1145579811786--
> --bqJky99mlBWa-ZuqjC53mG6EzbmlxB--
>
>
> Thanks
>
>
>
> --
> Sent from: http://cxf.547215.n5.nabble.com/cxf-user-f547216.html
>

Reply via email to