1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-08-13 17:03:48 -04:00
k-9/src/com/fsck/k9/mail/store/local/AttachmentMessageBodyUtil.java

34 lines
1.1 KiB
Java
Raw Normal View History

package com.fsck.k9.mail.store.local;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import org.apache.commons.io.IOUtils;
import org.apache.james.mime4j.util.MimeUtil;
import com.fsck.k9.mail.MessagingException;
import com.fsck.k9.mail.internet.MimeMessage;
public class AttachmentMessageBodyUtil {
public static void writeTo(BinaryAttachmentBody body, OutputStream out) throws IOException,
MessagingException {
InputStream in = body.getInputStream();
try {
if (MimeUtil.ENC_7BIT.equalsIgnoreCase(body.getEncoding())) {
/*
* If we knew the message was already 7bit clean, then it
* could be sent along without processing. But since we
* don't know, we recursively parse it.
*/
MimeMessage message = new MimeMessage(in, true);
message.setUsing7bitTransport();
message.writeTo(out);
} else {
IOUtils.copy(in, out);
}
} finally {
in.close();
}
}
}