Put Attachment Operation
-
Use the
PutAttachmentOperation
to add an attachment to a document. -
In this page:
Put attachment example
// Prepare content to attach
const text = "Some content...";
const byteArray = Buffer.from(text);
// Define the put attachment operation
const putAttachmentOp = new PutAttachmentOperation(
"employees/1-A", "attachmentName.txt", byteArray, "text/plain");
// Execute the operation by passing it to operations.send
const attachmentDetails = await documentStore.operations.send(putAttachmentOp);
Syntax
// Available overloads:
const putAttachmentOp = new PutAttachmentOperation(documentId, name, stream);
const putAttachmentOp = new PutAttachmentOperation(documentId, name, stream, contentType);
const putAttachmentOp = new PutAttachmentOperation(documentId, name, stream, contentType, changeVector);
Parameter | Type | Description |
---|---|---|
documentId | string |
Document ID to which the attachment will be added |
name | string |
Name of attachment to put |
stream | stream.Readable / Buffer |
A stream that contains the raw bytes of the attachment |
contentType | string |
Content type of attachment |
changeVector | string |
ChangeVector of attachment, used for concurrency checks ( null to skip check) |
Return Value of store.operations.send(putAttachmentOp) |
|
---|---|
object |
An object with the new attachment's details |
// The AttachmentDetails object:
// =============================
{
// Change vector of attachment
changeVector; // string
// ID of the document that contains the attachment
documentId?; // string
// Name of attachment
name; // string;
// Hash of attachment
hash; // string;
// Content type of attachment
contentType; // string
// Size of attachment
size; // number
}