---
title: "Get Attachments"
description: "Retrieve document attachments from RavenDB using the session API with code examples in C#, Java, Python, PHP, and Node.js."
url: "https://docs.ravendb.net/7.2/document-extensions/attachments/get-attachments"
version: "7.2"
language: "python"
---

# Get Attachments

> Client language: Python. Also available for [C#](https://docs.ravendb.net/7.2/document-extensions/attachments/get-attachments.md), [Java](https://docs.ravendb.net/7.2/document-extensions/attachments/get-attachments.java.md), [PHP](https://docs.ravendb.net/7.2/document-extensions/attachments/get-attachments.php.md), [Node.js](https://docs.ravendb.net/7.2/document-extensions/attachments/get-attachments.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."

Several methods allow you to download attachments from a database:

Use `session.advanced.attachments.get` to download an attachment or multiple attachments.  
Use `session.advanced.attachments.get_names` to get all the names of a document's attachments.  
Use `session.advanced.attachments.get_revision` to download an attachment of a document revision.  
Use `session.advanced.attachments.exists` to determine if an attachment exists on a document.

## Syntax

```python
def get(self, entity_or_document_id: str = None, name: str = None) -> CloseableAttachmentResult: ...

class CloseableAttachmentResult:
  def __init__(self, response: requests.Response, details: AttachmentDetails):
      self.__details = details
      self.__response = response

class AttachmentDetails(AttachmentName):
  def __init__(
      self, name: str, hash: str, content_type: str, size: int, change_vector: str = None, document_id: str = None
  ):
      super().__init__(...)
      ...

class AttachmentName:
  def __init__(self, name: str, hash: str, content_type: str, size: int): ...

def get_names(self, entity: object) -> List[AttachmentName]: ...

def exists(self, document_id: str, name: str) -> bool: ...
```

## Example I

```python
with store.open_session() as session:
  album = session.load("albums/1", Album)

  with session.advanced.attachments.get(album, "001.jpg") as file1:
      with session.advanced.attachments.get("albums/1", "002.jpg") as file2:
          bytes_data = file1.data

          attachment_details = file1.details
          name = attachment_details.name
          content_type = attachment_details.content_type
          hash_ = attachment_details.hash
          size = attachment_details.size
          document_id = attachment_details.document_id
          change_vector = attachment_details.change_vector

  attachment_names = session.advanced.attachments.get_names(album)
  for attachment_name in attachment_names:
      name = attachment_name.name
      content_type = attachment_name.content_type
      hash_ = attachment_name.hash
      size = attachment_name.size

  exists = session.advanced.attachments.exists("albums/1", "003.jpg")
```
