Java Code Examples for org.apache.james.mime4j.message.BodyPart#setContentDisposition()
The following examples show how to use
org.apache.james.mime4j.message.BodyPart#setContentDisposition() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MessageStoreImplAttachmentsTest.java From sling-samples with Apache License 2.0 | 5 votes |
private static BodyPart createTextBody(String text, String subtype, boolean isAttachment) { TextBody body = new StorageBodyFactory().textBody(text, MailArchiveServerConstants.DEFAULT_ENCODER.charset().name()); BodyPart bodyPart = new BodyPart(); if (isAttachment) { bodyPart.setContentDisposition("attachment", "file"+Math.random()); } bodyPart.setText(body, subtype); return bodyPart; }
Example 2
Source File: MessageStoreImplAttachmentsTest.java From sling-samples with Apache License 2.0 | 5 votes |
private static BodyPart createRandomBinaryAttachment(int numberOfBytes) throws IOException { byte[] data = new byte[numberOfBytes]; new Random().nextBytes(data); Body body = new StorageBodyFactory().binaryBody(new ByteArrayInputStream(data)); BodyPart bodyPart = new BodyPart(); bodyPart.setContentDisposition("attachment", "file"+Math.random()); bodyPart.setBody(body, "application/octet-stream"); return bodyPart; }