Download File
Download the full file as binary data using client.storage.downloadFile(). The result includes the file contents in bytes.
Function Signature
client.storage.downloadFile(params: DownloadFileParams): Promise<DownloadFileData | BolticErrorResponse>
Parameters
DownloadFileParams
| Field | Type | Required | Description |
|---|---|---|---|
file_name | string | ✅ | Full object path (same as list fullPath) |
sizeBytes | number or string | ❌ | Size in bytes; if omitted, the client resolves size when needed |
storageType | string | ❌ | Optional storage type |
Return Value
DownloadFileData
| Field | Type | Description |
|---|---|---|
bytes | ArrayBuffer | File contents |
status | number | Optional status metadata |
contentType | string | Optional MIME type hint |
Example
import { createClient, isErrorResponse } from "@boltic/sdk";
import { writeFileSync } from "fs";
const client = createClient("your-api-key");
const result = await client.storage.downloadFile({
file_name: "my-app/exports/data.csv",
});
if (isErrorResponse(result)) {
console.error(result.error.message);
} else {
writeFileSync("./data.csv", Buffer.from(result.bytes));
console.log("Saved", result.contentType, result.status);
}
With known size
const result = await client.storage.downloadFile({
file_name: "my-app/exports/data.csv",
sizeBytes: 1024,
});
Pass sizeBytes from a previous list() row’s size when you already have it so the download does not need to look up the size again.
Error handling
Treat isErrorResponse(result) before reading result.bytes.