下面列出了org.apache.http.entity.mime.FormBodyPart#getHeader ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* 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=\""+bodyPart.getName()+"\"; filename=\""+fileName+"\"");
contentID = "<"+fileName+">";
}
bodyPart.addField("Content-ID", contentID);
if(firstPart == null)
firstPart = contentID;
}
this.bodyParts.add(bodyPart);
return this;
}