users@jersey.java.net

RE: [Jersey] problem with multipart API when receiving BodyPartEntity

From: Gehl, Pascal <Pascal.Gehl_at_nuance.com>
Date: Wed, 22 Apr 2009 09:39:05 -0400

I don't know if was clear enough.

 

My problem is that for example my client adds a 900 000 bytes byte[] to
the multipart object and my server side only receives 600 000 bytes in
the BodyPartentity.

 

Between the 2 there is only jersey client API and jersey server API.

 

Has anybody experienced (and hopefully found a solution to) this problem
?

 

Pascal

________________________________

From: Gehl, Pascal
Sent: Wednesday, April 22, 2009 9:05 AM
To: users_at_jersey.dev.java.net
Subject: [Jersey] problem with multipart API when receiving
BodyPartEntity

 

Hi,

 

In my application I send 2 bodyparts ( the first is XML and the second
is an audio file (small):

 

MultiPart multiPart = new MultiPart().bodyPart(

new BodyPart(jaxbSchedulerTranscriptionRequest,

MediaType.APPLICATION_XML_TYPE)).bodyPart(

new BodyPart(audioByteArray, MediaType.APPLICATION_OCTET_STREAM_TYPE));

 

Builder jerseyBuilder = webResource.accept("multipart/mixed");

jerseyBuilder.entity(multiPart, "multipart/mixed");

ClientResponse clientResponse = jerseyBuilder.post(ClientResponse.class,
multiPart);

 

 

The server receives the Multipart object

 

@POST

@Consumes(""multipart/mixed"")

public Response receive(MultiPart multiPart) throws Exception {

Object generatedXMLRequest =
multiPart.getBodyParts().get(0).getEntityAs(getGeneratedXMLObjectClass()
);

 

BodyPartEntity bodyPartEntity = (BodyPartEntity)
multiPart.getBodyParts().get(1).getEntity();

InputStream audioStream = bodyPartEntity.getInputStream();

byte[] audioArray = IOUtils.toByteArray(audioStream);

 

My problem is that the number of bytes sent as audio (2nd bodypart) is
not equal to the number of bytes received.

 

Do I miss something ?

 

Thanks

 

PASCAL GEHL