You are currently browsing legacy 3.5 version of documentation. Click here to switch to the newest 5.1 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.


public void putAttachment(String key, Etag etag, InputStream data, RavenJObject metadata);
key String unique key under which attachment will be stored
etag Etag current attachment etag, used for concurrency checks (null to skip check)
data InputStream attachment data
metadata RavenJObject attachment metadata


try (FileInputStream fis = new FileInputStream("sea.png")) {
  RavenJObject metadata = new RavenJObject();
  metadata.add("Description", "Holidays 2014");
  .putAttachment("albums/holidays/sea.jpg", null, fis, metadata);