Upload
Upload a file with client.storage.upload(). Pass a Blob and a logical file name; optionally set a folder prefix and visibility.
Function Signature
client.storage.upload(params: UploadParams): Promise<UploadData | BolticErrorResponse>
Parameters
UploadParams (essential fields)
| Field | Type | Required | Description |
|---|---|---|---|
file | Blob | ✅ | File to upload |
filename | string | ✅† | Logical file name |
filepath | string | ❌ | Folder or prefix (e.g. "exports/") |
public | boolean or string | ❌ | Visibility (see below) |
expire_in | number or string | ❌ | Lifetime in minutes for a temporary public link (maximum 7 days; values above the limit are clamped) |
† One of filename or file_name is required.
Visibility (public)
publicomitted orfalse— Private object.public: truewithoutexpire_in— Permanent public access;public_urlmay be present when supported.public: truewithexpire_in— Temporary signed read URL;temporary_sharable_linkmay be present when supported.
If you omit public, you can still use the lower-level flags is_public, is_public_permanent, and expire_in on UploadParams when you need finer control.
Return Value
UploadData
| Field | Description |
|---|---|
message | Status message |
path | Stored object path — use with List, Delete, Download |
temporary_sharable_link | Temporary signed read URL, when applicable |
public_url | Permanent public URL, when applicable |
Example
import { createClient, isErrorResponse } from "@boltic/sdk";
const client = createClient("your-api-key");
const blob = new Blob([Buffer.from("hello")], { type: "text/plain" });
const result = await client.storage.upload({
file: blob,
filename: `report-${Date.now()}.txt`,
filepath: "reports",
});
if (isErrorResponse(result)) {
console.error(result.error.message);
} else {
console.log("Stored at:", result.path);
}
Temporary public link
const result = await client.storage.upload({
file: blob,
filename: "temp.txt",
filepath: "shared",
public: true,
expire_in: 120, // minutes
});
if (!isErrorResponse(result) && result.temporary_sharable_link) {
console.log("Temporary URL:", result.temporary_sharable_link);
}
Error handling
Always branch on isErrorResponse(result) before reading path or temporary_sharable_link.
Related
- Overview
- List — Find objects after upload
- Public & private — Change visibility after upload