Use attachment header to retrieve attachment.

This commit is contained in:
akwizgran
2019-06-18 13:52:37 +01:00
parent 34583e6d2d
commit ed20b2d8d6
9 changed files with 48 additions and 31 deletions

View File

@@ -374,13 +374,14 @@ class MessagingManagerImpl implements MessagingManager, IncomingMessageHook,
}
@Override
public Attachment getAttachment(MessageId m) throws DbException {
public Attachment getAttachment(AttachmentHeader h) throws DbException {
// TODO: Support large messages
MessageId m = h.getMessageId();
byte[] body = clientHelper.getMessage(m).getBody();
try {
BdfDictionary meta = clientHelper.getMessageMetadataAsDictionary(m);
int offset = meta.getLong(MSG_KEY_DESCRIPTOR_LENGTH).intValue();
return new Attachment(new ByteArrayInputStream(body, offset,
return new Attachment(h, new ByteArrayInputStream(body, offset,
body.length - offset));
} catch (FormatException e) {
throw new DbException(e);