SDK
Folders
Work with folders through the SDK
All folder operations live on vaze.folders. Every method returns the
response envelope.
The Folder object
type Folder = {
id: string;
name: string;
path: string; // location on the server's disk
parentId: string | null; // null for the root folder
createdAt: string;
updatedAt: string;
};Browse a folder
get() returns the files and direct subfolders of a folder. Call it with no
arguments for the root folder, or target a specific folder by id or by
path:
// root folder
const root = await vaze.folders.get();
// by id
const byId = await vaze.folders.get({ id: "folder-id" });
// by relative path
const byPath = await vaze.folders.get({ path: "projects/demo" });
// data => { files: File[], folders: Folder[] }It also accepts the same ListOptions as the
file methods to paginate and sort the files inside the folder:
const { data, error } = await vaze.folders.get({
path: "projects/demo",
limit: 50,
orderBy: "name",
orderDirection: "ASC",
});Create a folder
Pass a path relative to the root folder — intermediate folders are created automatically:
const { data, error } = await vaze.folders.create("projects/demo/assets");
// data => { folder: Folder } — the deepest folder in the pathFolder names cannot contain dots (
.).Rename a folder
const { error } = await vaze.folders.rename({
id: "folder-id",
name: "new-name",
});Renaming a folder also updates the paths of everything inside it. A sibling
folder with the same name causes a 409 error.
Delete a folder
const { error } = await vaze.folders.delete("folder-id");Deleting a folder removes the folder and all files and subfolders inside it from disk and the database. This cannot be undone.
Vaze