2

I am using Jersey 2.0 to generate REST responses. I have the following method which responses back a json text and octet-stream data (PDF):

@GET
@Produces("application/json", "multipart/mixed; boundary=Test")
public Response getInfo((@Context HttpHeaders header, @Context HttpServletResponse respo, @Context HttpServletRequest req) {

// Code to Create JSON (variable json below)
// Code to Fetch PDF document  (variable os is ByteArrayOutputStream)

// create bodyparts and return Response

 MimeMultipart multiPart = new MimeMultipart();
          MimeBodyPart mbp1 = new MimeBodyPart();
          mbp1.setContent(os.toByteArray(), MediaType.APPLICATION_OCTET_STREAM);

          MimeBodyPart mbp2 = new MimeBodyPart();
          mbp2.setContent(json, MediaType.APPLICATION_JSON);

          multiPart.addBodyPart(mbp2);
          multiPart.addBodyPart(mbp1); 


 return Response.ok(multiPart, "multipart/mixed;boundary=Test").build();

}

What is happening is I am getting the following output without my specified 'boundary'.

------=_Part_0_195280885.1377005531310

{"status":"ok","index":1}

------=_Part_0_195280885.1377005531310

BLA bla bla bla.... PDF version 1.4 .... adsas da sf sgf sdg startxref 42417 %%EOF

------=_Part_0_195280885.1377005531310--

Shouldn't Boundary be --Test ?

Am I missing something here?

Namenoobie
  • 541
  • 2
  • 8
  • 15

0 Answers0