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

@@ -1,15 +1,27 @@
package org.briarproject.briar.api.messaging;
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
import java.io.InputStream;
import javax.annotation.concurrent.Immutable;
@Immutable
@NotNullByDefault
public class Attachment {
private final AttachmentHeader header;
private final InputStream stream;
public Attachment(InputStream stream) {
public Attachment(AttachmentHeader header, InputStream stream) {
this.header = header;
this.stream = stream;
}
public AttachmentHeader getHeader() {
return header;
}
public InputStream getStream() {
return stream;
}

View File

@@ -40,7 +40,7 @@ public interface MessagingManager extends ConversationClient {
/**
* Stores a local attachment message.
*
* @throws FileTooBigException
* @throws FileTooBigException If the attachment is too big
*/
AttachmentHeader addLocalAttachment(GroupId groupId, long timestamp,
String contentType, InputStream is) throws DbException, IOException;
@@ -68,9 +68,9 @@ public interface MessagingManager extends ConversationClient {
String getMessageText(MessageId m) throws DbException;
/**
* Returns the attachment with the given ID.
* Returns the attachment with the given message ID and content type.
*/
Attachment getAttachment(MessageId m) throws DbException;
Attachment getAttachment(AttachmentHeader h) throws DbException;
/**
* Returns true if the contact with the given {@link ContactId} does support