TypeScript SDK
Listing & Management
Explore virtual folders, query hierarchical media trees, fetch asset download links, and perform atomic deletions.
Listing Files & Folders (`listContents`)
Retrieve all files and folders in a project root or within a specific virtual subfolder:
examples/list.ts
import { Cloudizero } from "@cloudizero/sdk";
const cz = new Cloudizero({ apiKey: process.env.CLOUDIZERO_API_KEY! });
// List root contents
const rootContents = await cz.storage.listContents({
projectId: "ca2454ff-7f1e-421b-b134-4c800f6d58de",
});
console.log("Root Folders:", rootContents.folders);
console.log("Root Files:", rootContents.files);
// List contents of a specific subfolder
const folderContents = await cz.storage.listContents({
projectId: "ca2454ff-7f1e-421b-b134-4c800f6d58de",
folderId: "profiles",
});
console.log("Current Breadcrumbs:", folderContents.breadcrumbs);Fetching Asset Metadata (`getFile`)
Fetch relational metadata and obtain a presigned download URL for private assets:
examples/get-file.ts
// Fetch file metadata and temporary presigned download link
const { file, downloadUrl } = await cz.storage.getFile("f29b8214-7e8c-...");
console.log("File Name:", file.name);
console.log("Size:", file.size);
console.log("Direct Download:", downloadUrl);Permanently Deleting Assets (`deleteFile`)
Deleting an asset is atomic: Cloudizero simultaneously purges the binary object from Cloudflare R2 and removes its record from Neon Postgres.
examples/delete.ts
// Permanently delete file from both Cloudflare R2 and Neon DB
const res = await cz.storage.deleteFile("f29b8214-7e8c-...");
if (res.success) {
console.log("Asset successfully removed:", res.message);
}Irreversible Action
Deleted files cannot be recovered. Ensure you prompt for confirmation in user interfaces before triggering asset deletion.