Storage
Upload and manage files using CassaDB Storage.
Storage allows you to upload, download, list and delete files associated with your project.
Upload a File
Upload a file from your application.
ts
const file = await db.storage.upload(
fileBlob,
"avatar.png",
);Parameters
- file (Blob | File) — File to upload.
- filename (string) — Name of the uploaded file.
Returns
ts
{
id: "file_01JY...",
name: "avatar.png",
size: 124812,
contentType: "image/png",
}List Files
Retrieve all uploaded files.
ts
const files = await db.storage.list();Download a File
Download a file using its ID.
ts
const blob = await db.storage.download(
file.id,
);The SDK returns the downloaded file as a Blob.
Delete a File
Delete a file permanently.
ts
await db.storage.delete(
file.id,
);Deleted files cannot be recovered.
Example
ts
const file = await db.storage.upload(
fileBlob,
"avatar.png",
);
const files = await db.storage.list();
const downloaded = await db.storage.download(
file.id,
);
await db.storage.delete(
file.id,
);Supported File Types
Storage accepts any file type, including:
- Images
- Videos
- Audio
- Documents
- Archives
- Binary files