> ## Documentation Index
> Fetch the complete documentation index at: https://urbackend-docs-sdk-v0-2-2.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Storage

> Upload files and get back public CDN URLs using the SDK storage module.

Access storage methods via `client.storage`. Uploaded files are served from a public CDN — no extra configuration required.

<Note>
  Storage operations accept both `pk_live_...` and `sk_live_...` keys. Use `pk_live_...` in browser code for user-initiated uploads, and `sk_live_...` for server-side uploads. Never expose your secret key in browser code.
</Note>

***

## upload

Upload a file to storage.

```typescript theme={null}
upload(file: File | Blob | Buffer, filename?: string): Promise<UploadResponse>
```

**Parameters**

| Name | Type | Required | Description |
| - | - | - | - |
| `file` | `File \| Blob \| Buffer` | Yes | The file to upload. |
| `filename` | `string` | No | Override the stored filename. |

**Returns (`UploadResponse`)**

| Field | Type | Description |
| - | - | - |
| `url` | `string` | Public CDN URL for the uploaded file. |
| `path` | `string` | Storage path — required to delete the file later. |
| `provider` | `'internal' \| 'external'` | Whether the file is stored on urBackend or your own Supabase. |

<Note>
  Store the `path` alongside the `url` in your database. You need it to delete the file.
</Note>

**Example — browser file input**

```typescript theme={null}
const input = document.querySelector<HTMLInputElement>('input[type="file"]');

if (!input?.files?.length) {
  throw new Error('No file selected');
}

const file = input.files[0];

const { url, path, provider } = await client.storage.upload(file);
console.log(url);  // 'https://cdn.example.com/uploads/abc123.jpg'
console.log(provider); // 'internal'
```

***

## deleteFile

Delete a previously uploaded file by its storage path.

```typescript theme={null}
deleteFile(path: string): Promise<{ deleted: boolean }>
```

**Parameters**

| Name | Type | Required | Description |
| - | - | - | - |
| `path` | `string` | Yes | The `path` returned by `upload()`. |

***

## Limits

| Limit | Value |
| - | - |
| Max file size | 10 MB per file |
| Total storage per project | 100 MB (Free Tier) |

<Note>
  Uploads that exceed 10 MB are rejected with a `StorageError`.
</Note>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.