I'm trying to retrieve content of MIME multipart using BodyPart as follow
ByteArrayOutputStream baos = null;
MimeMultipart mp = new MimeMultipart(new ByteArrayDataSource(inputStream, contentType));
int count = mp.getCount();
baos = new ByteArrayOutputStream();
for (int i = 0; i < count; i++) {
BodyPart bodyPart = mp.getBodyPart(i);
Object content = bodyPart.getContent();
if (content instanceof InputStream) {
// process inputStream
}
bodyPart.writeTo(MIMEbaos);
String attachment = MIMEbaos.toString();
}
But bodyPart.getContent() is providing the same InputStream as whole MIME message when I expect just a content (without content-type, boundaries etc) when attachment contains whole MIME multipart body section including content-type, etc.
InputStream is from
ByteArrayOutputStream baos = new ByteArrayOutputStream();
msg.writeTo(baos);
byte[] bytes = baos.toByteArray();
InputStream inputStream = new ByteArrayInputStream(bytes);
where msg is SOAPMessage MIME type as MTOM
bodyPart.getDisposition()comes as null andbodyPart.getContent()comes as Byte Array Input Stream not a String. I'm expecting, at least forbodyPart.getContent()to see current content (plain) of the MIME multipart w/o related headers. - JackTheKnifeinputStreamcome from? Are you sure it’s a multi-part MIME message? - VGR