Skip to main content

Operations: Attachments: How to Put an Attachment

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

Syntax

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;
}
Parameters
documentIdstringID of a document which will contain an attachment
namenameName of an attachment
streamStreamStream contains attachment raw bytes
contentTypestringMIME type of attachment
changeVectorstringEntity changeVector, used for concurrency checks (null to skip check)
Return Value
ChangeVectorChange vector of created attachment
DocumentIdID of document
NameName of created attachment
HashHash of created attachment
ContentTypeMIME content type of attachment
SizeSize of attachment

Example

AttachmentDetails attachmentDetails =
store.Operations.Send(
new PutAttachmentOperation("orders/1-A",
"invoice.pdf",
stream,
"application/pdf"));