> ## Documentation Index
> Fetch the complete documentation index at: https://docs.drime.cloud/llms.txt
> Use this file to discover all available pages before exploring further.

# Download File

> Download a file or folder

## Overview

Downloads a file by its hash. For folders, the contents are automatically zipped.

## Path Parameters

<ParamField path="hash" type="string" required>
  The file entry hash (e.g., `MzI2MHxwYWRkaQ`)
</ParamField>

## Response

Returns the file content with appropriate `Content-Type` and `Content-Disposition` headers.

* For single files: The file is downloaded directly
* For folders: A ZIP archive is created and downloaded

<RequestExample>
  ```bash cURL theme={null}
  # Download a file
  curl -O -J https://app.drime.cloud/api/v1/file-entries/download/MzI2MHxwYWRkaQ \
    -H "Authorization: Bearer YOUR_ACCESS_TOKEN"

  # -O: Save with original filename
  # -J: Use filename from Content-Disposition header
  ```

  ```javascript JavaScript theme={null}
  const hash = 'MzI2MHxwYWRkaQ';

  const response = await fetch(
    `https://app.drime.cloud/api/v1/file-entries/download/${hash}`,
    {
      headers: {
        'Authorization': 'Bearer YOUR_ACCESS_TOKEN'
      }
    }
  );

  // Get filename from Content-Disposition header
  const disposition = response.headers.get('Content-Disposition');
  const filename = disposition?.match(/filename="(.+)"/)?.[1] || 'download';

  // Download the file
  const blob = await response.blob();
  const url = URL.createObjectURL(blob);

  const a = document.createElement('a');
  a.href = url;
  a.download = filename;
  a.click();

  URL.revokeObjectURL(url);
  ```

  ```python Python theme={null}
  import requests

  hash = 'MzI2MHxwYWRkaQ'

  response = requests.get(
      f'https://app.drime.cloud/api/v1/file-entries/download/{hash}',
      headers={'Authorization': 'Bearer YOUR_ACCESS_TOKEN'},
      stream=True
  )

  # Get filename from Content-Disposition header
  content_disposition = response.headers.get('Content-Disposition', '')
  filename = content_disposition.split('filename="')[1].rstrip('"') if 'filename=' in content_disposition else 'download'

  # Save file
  with open(filename, 'wb') as f:
      for chunk in response.iter_content(chunk_size=8192):
          f.write(chunk)

  print(f'Downloaded: {filename}')
  ```
</RequestExample>

<ResponseExample>
  ```
  HTTP/1.1 200 OK
  Content-Type: image/jpeg
  Content-Disposition: attachment; filename="photo.jpg"
  Content-Length: 2048576

  [binary file content]
  ```
</ResponseExample>

<Note>
  For folders, the response will have `Content-Type: application/zip` and the filename will end with `.zip`.
</Note>
