Get Attachment Operation

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 Specify whether getting an attachment from a document or from a revision.
(DOCUMENT or REVISION).
changeVector String The ChangeVector of the document or the revision to which the attachment belongs.
Mandatory when getting an attachment from a revision.
Used for concurrency checks (use null to skip the check).
Return Value
Stream InputStream containing an attachment
ChangeVector Change vector of document
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));