Skip to main content

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)​

FieldTypeRequiredDescription
fileBlob✅File to upload
filenamestring✅†Logical file name
filepathstring❌Folder or prefix (e.g. "exports/")
publicboolean or string❌Visibility (see below)
expire_innumber 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)​

  • public omitted or false — Private object.
  • public: true without expire_in — Permanent public access; public_url may be present when supported.
  • public: true with expire_in — Temporary signed read URL; temporary_sharable_link may 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​

FieldDescription
messageStatus message
pathStored object path — use with List, Delete, Download
temporary_sharable_linkTemporary signed read URL, when applicable
public_urlPermanent 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);
}
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.