You are currently browsing legacy 3.0 version of documentation. Click here to switch to the newest 4.2 version.

We can help you with migration to the latest RavenDB

Contact Us Now
see on GitHub

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
key string unique key under which attachment will be stored
etag Etag current attachment etag, used for concurrency checks (null to skip check)
data Stream attachment data
metadata RavenJObject attachment 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" }
			                                           });
}