Skip to main content

Attachments: How to Update Only Attachment Metadata

UpdateAttachmentMetadata is used to update an attachment's metadata in a database.

Syntax

void UpdateAttachmentMetadata(string key, Etag etag, RavenJObject metadata);
Parameters
keystringkey under which attachment is stored
etagEtagcurrent attachment Etag, used for concurrency checks (null to skip check)
metadataRavenJObjectattachment metadata

Example

JsonDocumentMetadata attachment = store.DatabaseCommands.Head("albums/holidays/sea.jpg");
RavenJObject metadata = attachment.Metadata;
metadata["Description"] = "Holidays 2012";

store
.DatabaseCommands
.UpdateAttachmentMetadata("albums/holidays/sea.jpg", attachment.Etag, metadata);