Drivebase Logo

Files Methods

Most-used @drivebase/sdk file methods with examples.

Use client.files for file listing, lookup, search, and mutations.

list

Get paginated files from a folder.

const page = await client.files.list({
  folderId: "folder_123", // optional
  limit: 20,
  offset: 0,
});

console.log(page.files, page.total, page.hasMore);

get

Get a single file by ID.

const file = await client.files.get("file_123");
console.log(file.name, file.virtualPath);

contents

Fetch both files and folders for a location.

const contents = await client.files.contents({
  folderId: "folder_123", // optional
  providerIds: ["provider_a", "provider_b"], // optional
});

console.log(contents.folder, contents.files, contents.folders);

Search file names.

const matches = await client.files.search("invoice", 20);

smartSearch

Search extracted file content (semantic/full-text style).

const results = await client.files.smartSearch("Q4 revenue", 10);
for (const result of results) {
  console.log(result.file.name, result.headline, result.rank);
}

recent and starred

Get recent or starred files.

const recent = await client.files.recent({ limit: 10 });
const starred = await client.files.starred();

rename, move, delete

Mutate file metadata/location.

await client.files.rename("file_123", "renamed-report.pdf");
await client.files.move("file_123", "target_folder_id");
await client.files.delete("file_123");

Pass null or undefined as folder ID in move to move file to root.

star and unstar

await client.files.star("file_123");
await client.files.unstar("file_123");

On this page