see on GitHub

Operations: Attachments: How to Get an Attachment

This operation is used to get an attachment from a document.

Syntax

GetAttachmentOperation(String documentId, String name, AttachmentType type, String changeVector)

public class CloseableAttachmentResult implements AutoCloseable {
    private AttachmentDetails details;
    private CloseableHttpResponse response;

    public InputStream getData() throws IOException {
        return response.getEntity().getContent();
    }

    public AttachmentDetails getDetails() {
        return details;
    }
}

public class AttachmentDetails extends Foo.AttachmentName {
    private String changeVector;
    private String documentId;

    public String getChangeVector() {
        return changeVector;
    }

    public void setChangeVector(String changeVector) {
        this.changeVector = changeVector;
    }

    public String getDocumentId() {
        return documentId;
    }

    public void setDocumentId(String documentId) {
        this.documentId = documentId;
    }
}

public class AttachmentName {
    private String name;
    private String hash;
    private String contentType;
    private long size;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getHash() {
        return hash;
    }

    public void setHash(String hash) {
        this.hash = hash;
    }

    public String getContentType() {
        return contentType;
    }

    public void setContentType(String contentType) {
        this.contentType = contentType;
    }

    public long getSize() {
        return size;
    }

    public void setSize(long size) {
        this.size = size;
    }
}

Parameters
documentId String ID of a document which will contain an attachment
name String Name of an attachment
type AttachmentType DOCUMENT or REVISION
changeVector String Entity changeVector, used for concurrency checks (null to skip check)
Return Value
Stream InputStream containing an attachment
ChangeVector Change vector of an attachment
DocumentId ID of document
Name Name of attachment
Hash Hash of attachment
ContentType MIME content type of an attachment
Size Size of attachment

Example

store.operations().send(
    new GetAttachmentOperation("orders/1-A", "invoice.pdf", AttachmentType.DOCUMENT, null));