/** * Write the multipart header fields; depends on the style. */ protected void formatMultipartHeader( final FormBodyPart part, final OutputStream out) throws IOException { // For strict, we output all fields with MIME-standard encoding. final Header header = part.getHeader(); for (final MinimalField field: header) { writeField(field, out); } }
public MultipartEntityBuilder addPart(FormBodyPart bodyPart) { if (bodyPart == null) { return this; } if (this.bodyParts == null) { this.bodyParts = new ArrayList<FormBodyPart>(); } if(mtom) { Header header = bodyPart.getHeader(); String contentID; String fileName = bodyPart.getBody().getFilename(); header.removeFields("Content-Disposition"); if(fileName == null) { contentID = "<"+bodyPart.getName()+">"; } else { bodyPart.addField("Content-Disposition", "attachment; name=\""+fileName+"\"; filename=\""+fileName+"\""); contentID = "<"+fileName+">"; } bodyPart.addField("Content-ID", contentID); if(firstPart == null) firstPart = contentID; } this.bodyParts.add(bodyPart); return this; }