FILE Columns & Uploads
@kalamdb/client supports file upload and retrieval patterns for KalamDB FILE columns.
Upload files with SQL
Use queryWithFiles(sql, files, params?, onProgress?):
Insert + read FileRefs (end-to-end)
downloadUrl() returns the authenticated file-download endpoint for the stored
file path:
Fetch it with the same bearer token you use for SQL calls:
For user tables, SDK helpers intentionally generate an owner-scoped URL without
user_id. A normal user can download only files in their own user-table scope.
Service-role clients may upload or write through authorized EXECUTE AS USER
flows, but raw cross-user FILE downloads are reserved for dba and system
tokens that explicitly add an authorized user_id query parameter.
Progress callback
In browser environments (XMLHttpRequest available), pass onProgress:
Auth behavior
From source:
- SDK builds auth header via
buildAuthHeader(auth) - sends multipart request to
POST /v1/api/sql - falls back to
fetchwhen XHR progress is unavailable
FileRef model
file_ref.ts exposes FileRef and helpers:
Parse and use file metadata
When rows come from queryOne/queryAll, FILE values are KalamCellValue:
Build download URL
That URL points at /v1/files/.../{stored_name} and uses the sanitized stored
filename, not the raw file id alone.
Type helpers
Storage-path internals documented by source
FileRef includes:
id,sub,name,size,mime,sha256, optionalshard- filename sanitization and extension normalization
- shared-table shard-aware
relativePath()generation
This is useful for building file galleries, attachment viewers, and audit tooling.