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

# File Storage Endpoints

> S3-based file upload, download, and management

> **Source:** Cross-cutting guide — references `equa-server/modules/file-storage/` used by `organization-endpoints.ts`, `data-room-endpoints.ts`, and `microsoft-endpoints.ts`

# File Storage Endpoints

Equa uses **Amazon S3** for file storage. The file storage module provides upload middleware, download handlers, and file management utilities used across multiple endpoint groups.

## Architecture

The file storage module (`file-storage`) is a shared library used by:

* **Organization endpoints** — organization-level file uploads
* **Data Room endpoints** — data room document uploads
* **Microsoft endpoints** — hybrid Microsoft/S3 document storage
* **Cap Table endpoints** — certificate PDF storage

Files are stored in S3 with the bucket and credentials configured via environment variables.

## Configuration

| Variable                         | Description                                         |
| -------------------------------- | --------------------------------------------------- |
| `AWS_S3_ACCESS_KEY`              | S3 access key                                       |
| `AWS_S3_SECRET_KEY`              | S3 secret key                                       |
| `AWS_S3_REGION`                  | S3 region                                           |
| `AWS_S3_BUCKET`                  | S3 bucket name                                      |
| `AWS_S3_UPLOAD_SIZE_LIMIT_MB`    | Max upload size for organization files (default 10) |
| `DATA_ROOM_UPLOAD_SIZE_LIMIT_MB` | Max upload size for data room files (default 10)    |

## Upload

### Organization File Upload

```
POST /v1/organization/:organization/file
```

| Field        | Value                 |
| ------------ | --------------------- |
| Auth         | Required              |
| Permission   | `canEditDocuments`    |
| Content-Type | `multipart/form-data` |

Upload a file to the organization's S3 storage. The upload middleware handles multipart parsing and streams the file to S3.

**Request:** Multipart form with a `file` field.

**Size limit:** Configurable via `AWS_S3_UPLOAD_SIZE_LIMIT_MB` (default 10 MB).

***

### Data Room Upload

```
POST /v1/organization/:organization/document
```

| Field        | Value                 |
| ------------ | --------------------- |
| Auth         | Required              |
| Permission   | `canEditDocuments`    |
| Content-Type | `multipart/form-data` |

Upload documents to the data room. Supports multiple file uploads.

**Size limit:** Configurable via `DATA_ROOM_UPLOAD_SIZE_LIMIT_MB` (default 10 MB).

***

## Download

### Download as Attachment

```
GET /v1/file/:file/content
```

| Field      | Value         |
| ---------- | ------------- |
| Auth       | Required      |
| Permission | `canViewFile` |

Download a file from S3 with `Content-Disposition: attachment`. The browser will prompt to save the file.

***

### View Inline

```
GET /v1/file/:file/content/:name
```

| Field      | Value         |
| ---------- | ------------- |
| Auth       | Required      |
| Permission | `canViewFile` |

Serve a file from S3 with `Content-Disposition: inline`. The browser will attempt to display the file (PDFs, images).

The `:name` parameter is used for the filename in the response headers and does not affect which file is served.

***

### Data Room Download

```
GET /v1/organization/:organization/document/:document/content
```

| Field      | Value              |
| ---------- | ------------------ |
| Auth       | Required           |
| Permission | `canViewDocuments` |

Download a data room document as an attachment.

***

### Data Room View Inline

```
GET /v1/organization/:organization/document/:document/content/:name
```

| Field      | Value              |
| ---------- | ------------------ |
| Auth       | Required           |
| Permission | `canViewDocuments` |

View a data room document inline in the browser.

## Upload Middleware

The file storage module provides reusable upload middleware:

* `uploadMiddlewareUsingMemory` — parses multipart uploads into memory buffers before uploading to S3
* Supports configurable max file size in megabytes
* Supports single or multiple file uploads (`UploadPlurality.single` / `UploadPlurality.multiple`)

## Related

* [Wallet Endpoints](/api/endpoints/wallet-endpoints) — blockchain wallet address management (separate from file storage)
