users@jersey.java.net

Re: [Jersey] Re: Multipart MessageBodyReader MessageBodyWriter

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Tue, 29 Jun 2010 17:31:55 +0200

Hi Mathew,

Your code looks almost fine. When returning a response you can do:

   Response.ok(multiPart, MultiPartMediaTypes.MULTIPART_MIXED).build();

Also note the media type is not really correct as you are not
returning form data (with named body parts) so multipart/mixed is more
appropriate.

Paul.

On Jun 29, 2010, at 5:18 PM, mathewch wrote:

>
> Hi Paul,
>
> Appreciate your quick response.
>
> I managed to have it working this way:
>
> In my services:
>
> MultiPart multiPart = new MultiPart();
> multiPart.bodyPart(new BodyPart(response.getReceipts(),
> MediaType.APPLICATION_OCTET_STREAM_TYPE));
> return
> Response
> .status
> (Status
> .OK).entity(multiPart).type(MediaType.MULTIPART_FORM_DATA).build();
>
>
> In my client:
> MultiPart multiPart = clientResponse.getEntity(MultiPart.class);
> byte[] response =
> multiPart.getBodyParts().get(0).getEntityAs(byte[].class);
>
> Is this the right way to do it?
>
> Thanks,
> Mathew
> --
> View this message in context: http://jersey.576304.n2.nabble.com/Multipart-MessageBodyReader-MessageBodyWriter-tp5234675p5235417.html
> Sent from the Jersey mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>