You are currently browsing legacy 4.0 version of documentation. Click here to switch to the newest 5.1 version.

We can help you with migration to the latest RavenDB

Contact Us Now
see on GitHub

Operations: Attachments: How to Put an Attachment

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


public PutAttachmentOperation(string documentId, 
        string name, 
        Stream stream, 
        string contentType = null, 
        string changeVector = null)

public class AttachmentDetails : AttachmentName
    public string ChangeVector;
    public string DocumentId;

public class AttachmentName
    public string Name;
    public string Hash;
    public string ContentType;
    public long Size;
documentId string ID of a document which will contain an attachment
name name Name of an attachment
stream Stream 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 =
        new PutAttachmentOperation("orders/1-A",