Operations: Attachments: How to Put an Attachment

This operation is used to put an attachment to a document.


PutAttachmentOperation(String documentId, String name, InputStream stream)

PutAttachmentOperation(String documentId, String name, InputStream stream, String contentType)

PutAttachmentOperation(String documentId, String name, InputStream stream, String contentType, String changeVector)

public class AttachmentDetails extends 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;
documentId String ID of a document which will contain an attachment
name String Name of an attachment
stream InputStream Stream contains attachment raw bytes
contentType String MIME type of attachment
changeVector String Entity changeVector, used for concurrency checks (null to skip check)
Return Value
ChangeVector Change vector of created attachment
DocumentId ID of document
Name Name of created attachment
Hash Hash of created attachment
ContentType MIME content type of attachment
Size Size of attachment


AttachmentDetails attachmentDetails = store
    .operations().send(new PutAttachmentOperation("orders/1-A",