How to process each part from multipart response in Java from javax.mail.internet.MimeMultipart API

198 Views Asked by At

ByteArrayDataSource datasource = new ByteArrayDataSource(in, "multipart/form-data"); MimeMultipart multipart = new MimeMultipart(datasource);

int count = multipart.getCount();
log.debug("count " + count);
for (int i = 0; i < count; i++) {
    BodyPart bodyPart = multipart.getBodyPart(i);
    if (bodyPart.isMimeType("multipart/mixed")) {
        log.info("multipart/mixed" + bodyPart.getContentType());
        processMultipart(bodyPart.getContent());
    } else if (bodyPart.isMimeType("application/json")) {
     
       
    } else {
        log.warn("default " + bodyPart.getContentType());
    }
}
0

There are 0 best solutions below