# CloudStorageProvider

**Kind:** Class

**Source:** [`atloria-monorepo/libs/parser-core/src/storage/cloud-storage.provider.ts`](https://github.com/sherkety/atloria/blob/main/atloria-monorepo/libs/parser-core/src/storage/cloud-storage.provider.ts#L26)

Cloud storage provider implementation

**Implements:** `IStorageProvider`

## Methods

| Method | Signature | Returns |
|---|---|---|
| `getMode` | `getMode()` | `StorageMode` |
| `saveScreenshot` | `saveScreenshot(buffer: Buffer, metadata: ScreenshotMetadata)` | `Promise<ScreenshotSaveResult>` |
| `findExistingScreenshot` | `findExistingScreenshot(metadata: Partial<ScreenshotMetadata>)` | `Promise<ScreenshotSaveResult | null>` |
| `saveDocument` | `saveDocument(document: DocumentMetadata)` | `Promise<DocumentSaveResult>` |
| `documentExists` | `documentExists(projectId: string, categoryPath: string[], slug: string)` | `Promise<boolean>` |
| `listDocuments` | `listDocuments(projectId: string, categoryPath: string[])` | `Promise<Array<{ id: string; title: string; slug: string; url: string }>>` |

## Where it refuses work

- `CloudStorageProvider` stops the work with `Error` when `!config?.apiBaseUrl` — “CloudStorageProvider requires a non-empty apiBaseUrl”.
- `CloudStorageProvider` stops the work with `Error` when `!config.projectId` — “CloudStorageProvider requires a non-empty projectId”.
- `CloudStorageProvider` stops the work with an early return when `!categoryId`, in 2 places.
- `CloudStorageProvider` stops the work with an early return when `existing`.
- `CloudStorageProvider` stops the work with an early return when `!category`.

## When something fails

- `CloudStorageProvider` handles failure in 5 places: it turns it into a return value in all 5.
