---
title: "Attachments Overview"
description: "Store, retrieve, and manage binary files as document attachments in RavenDB with support for streams, metadata, and transactional operations."
url: "https://docs.ravendb.net/7.2/document-extensions/attachments/overview"
version: "7.2"
language: "csharp"
---

# Attachments Overview

> Client language: C#. Also available for [Java](https://docs.ravendb.net/7.2/document-extensions/attachments/overview.java.md), [Node.js](https://docs.ravendb.net/7.2/document-extensions/attachments/overview.nodejs.md).
>
> RavenDB publishes an official agent skill for coding assistants at https://docs.ravendb.net/skills/ravendb/SKILL.md (also installable with `npx skills add ravendb/skills`). The skill describes itself as: "Read this before writing any RavenDB query, client call or /databases/ request. Covers server setup, document modelling, the Node.js, .NET and Python clients, RQL, indexes, vector search and AI agents. Code written from recall tends to run and return the wrong rows, because RQL resembles SQL and the clients take field names as plain strings."

> **Note**
>
> - RavenDB allows you to store files, such as images, PDFs, videos, text files, or any other format, as **attachments** alongside your JSON documents.
>
> - Each attachment is associated with a specific document and is identified by a unique name and an optional content type (e.g. *image/png*, *application/pdf*).
>   A single document can have any number of attachments, which are listed in the document’s metadata.
>
> - Attachments are stored as **binary data**, regardless of content type, and are handled as streams to enable efficient upload and retrieval.
>
> - Attachments can be stored **locally** on your RavenDB server,
>   or **remotely** in external storage such as Amazon S3 or any S3-compatible storage service, or Azure Blob Storage.
>
>   - **LOCAL storage**:  
>     By default, attachments are stored locally in RavenDB's internal storage.  
>     They are stored separately from the document itself in a dedicated attachment storage.  
>     This avoids bloating your JSON document with large binary content.  
>     See [Store attachments in local storage](https://docs.ravendb.net/7.2/document-extensions/attachments/store-attachments/store-attachments-local.md).
>   - **REMOTE storage**:  
>     RavenDB does not enforce a hard limit on the size of locally stored attachments.  
>     However, to reduce local disk usage, you can optionally configure RavenDB to offload attachments to remote storage.
>     See [Store attachments in remote storage](https://docs.ravendb.net/7.2/document-extensions/attachments/store-attachments/store-attachments-remote.md).
>
> - In this article:
>   - [Attachments in the documents list view](#attachments-in-the-documents-list-view)
>   - [Attachments in the document view](#attachments-in-the-document-view)
>   - [Attachments stats](#attachments-stats)

## Attachments in the documents list view {#attachments-in-the-documents-list-view}

![Document with attachments - list view](https://docs.ravendb.net/assets/images/document-with-attachments-1-beec8adab914d0e31ceceac5b2e3ce85.png)

1. Open the *Documents* section in Studio's navigation bar.
2. Select a collection (e.g., *Employees*) to display the documents list view.
3. The attachment flag is displayed for any document that has one or more attachments.

## Attachments in the document view {#attachments-in-the-document-view}

![Document with attachments](https://docs.ravendb.net/assets/images/document-with-attachments-2-a6c018bdcca3db5c477e6e7ff3f3397d.png)

1. **The document ID**:  
   The unique identifier of the document.

2. **Document metadata**:  
   Studio does not show the full attachment metadata in the document editor.  
   It only shows the `@flags` property with the value `HasAttachments` in the document's `@metadata` section
   to indicate that the document has attachments.

3. **Viewing the full metadata**:  
   Click this JSON button to view the document's raw content, including its full metadata.  
   You can also get the metadata programmatically using the Client API, see [Get entity metadata](https://docs.ravendb.net/7.2/client-api/session/how-to/get-and-modify-entity-metadata.md).  
   For details on the structure of attachment metadata, refer to:
   - [The attachment metadata - local](https://docs.ravendb.net/7.2/document-extensions/attachments/store-attachments/store-attachments-local.md#the-attachment-metadata)
   - [The attachment metadata - remote](https://docs.ravendb.net/7.2/document-extensions/attachments/store-attachments/store-attachments-remote.md#the-attachment-metadata)

4. **Attachments tab**:  
   All attachments associated with the document are listed under the *Attachments* tab in the document *Properties* pane.

5. **Add attachment to local storage**:  
   Click to add a new attachment to the document that will be stored in RavenDB's local storage.  
   Learn more in [Store attachments in local storage](https://docs.ravendb.net/7.2/document-extensions/attachments/store-attachments/store-attachments-local.md).

6. **Add attachment to remote storage**:  
   Click to add a new attachment to the document that will be uploaded and stored in a remote destination.  
   Learn more in [Store attachments in remote storage](https://docs.ravendb.net/7.2/document-extensions/attachments/store-attachments/store-attachments-remote.md).

7. **Storage location**:  
   The clip icon indicates where the attachment content is stored:
   - Purple clip: The attachment is stored locally on the RavenDB server.
   - Blue clip: The attachment is stored remotely (e.g., in Amazon S3 or Azure Storage).

8. **Attachment name**:  
   The name assigned to the attachment when it was added to the document.

9. **Attachment size**:  
   The size of the attachment file.

10. **Remote attachment details**:  
    Additional information specific to the remote attachment such as upload time and destination identifier.

11. **Delete attachment**:  
    Click to remove the attachment from the document and delete it from local RavenDB storage.  
    Learn more in [Delete attachments](https://docs.ravendb.net/7.2/document-extensions/attachments/delete-attachment.md).

## Attachments stats {#attachments-stats}

### View attachments stats in Studio

> **Info**
>
> The attachment counts shown in this section are part of Studio's Stats view.  
> Learn about the whole view in
> [Stats view](https://docs.ravendb.net/7.2/monitoring/statistics/stats-view.md).

The overall number of attachments in the database can be viewed in Studio's **General Database Stats** view.

![Attachments stats](https://docs.ravendb.net/assets/images/attachments-stats-1-d2b2d2dd737aa9dff0f7e7311fd241b1.png)

1. Go to the **Stats** section in Studio's navigation bar.
2. This it the total number of attachments in the database, from all collections.
3. Click "Show detailed database & indexing stats" to expand the detailed section.

![Attachments stats](https://docs.ravendb.net/assets/images/attachments-stats-2-4d8d876d7b908130d01593acc3e382a5.png)

4. **Attachments details**:  
   `total`:  
   The total number of attachments in the database, from all collections.  
   `unique`:  
   The number of unique attachments stored **locally** in the database.  
   Learn more in [Deduplicating local attachments](https://docs.ravendb.net/7.2/document-extensions/attachments/store-attachments/store-attachments-local.md#deduplicating-local-attachments).  
   `remote`:  
   The total number of attachments stored in remote storage.

---

### Get attachments stats via the Client API

Use the `GetDetailedStatisticsOperation` to retrieve statistics about attachments in the database.  
For a list of all available statistics properties, see the [Client API](https://docs.ravendb.net/7.2/monitoring/statistics/client-api.md) page.

#### Get\_stats\_operation

```csharp
var detailedStats = store.Maintenance.Send(new GetDetailedStatisticsOperation());

// Total number of attachments in the database (Local & Remote)
var totalAttachments = detailedStats.CountOfAttachments;

// Total number of unique attachments in the database (Local only)
var uniqueLocalAttachments = detailedStats.CountOfUniqueAttachments;

// Total number of Remote attachments in the database
var remoteAttachments = detailedStats.CountOfRemoteAttachments;  
```

#### Get\_stats\_operation\_async

```csharp
var detailedStats = await store.Maintenance.SendAsync(new GetDetailedStatisticsOperation());

// Total number of attachments in the database (Local & Remote)
var totalAttachments = detailedStats.CountOfAttachments;

// Total number of unique attachments in the database (Local only)
var uniqueLocalAttachments = detailedStats.CountOfUniqueAttachments;

// Total number of Remote attachments in the database
var remoteAttachments = detailedStats.CountOfRemoteAttachments;  

```
