Skip to main content

Attachments: Put

PutAttachment is used to insert or update an attachment in a database.

Syntax

void PutAttachment(string key, Etag etag, Stream data, RavenJObject metadata);
Parameters
keystringunique key under which attachment will be stored
etagEtagcurrent attachment etag, used for concurrency checks (null to skip check)
dataStreamattachment data
metadataRavenJObjectattachment metadata

Example

using (var file = File.Open("sea.png", FileMode.Open))
{
store
.DatabaseCommands
.PutAttachment("albums/holidays/sea.jpg", null, file, new RavenJObject
{
{ "Description", "Holidays 2014" }
});
}