Every method on this page lives on app.files:
const app = await api.applications.fetch("abc123def456abc123def456");
app.files; // FilesModule
Listing files in a directory
app.files.list(path?) returns the entries of a directory. The path defaults to "/".
const entries = await app.files.list("/");
console.log(entries);
// [
// { type: "file", name: "index.js", size: 123, lastModified: 1717084800000 },
// { type: "directory", name: "src", size: 0, lastModified: 1717084800000 },
// ]
Reading a file
app.files.read(path) returns a Node.js Buffer with the file contents, or undefined when the file is missing.
const buffer = await app.files.read("/index.js");
console.log(buffer?.toString("utf8"));
Creating or overwriting a file
app.files.create(file, fileName, path?) writes a file at path/fileName. The path defaults to "/".
| Parameter | Type | Description |
|---|
file | string | Buffer | A local file path or the raw Buffer content |
fileName | string | File name with extension (e.g. "version.ts") |
path | string | Absolute directory path inside the app (default "/") |
From a Buffer
From a local path
const content = Buffer.from("export default 1\n");
await app.files.create(content, "version.ts", "/src");
import { join } from "node:path";
const localPath = join(__dirname, "version.ts");
await app.files.create(localPath, "version.ts", "/src");
The signature changed in v4. Previous versions accepted create(content, fullPath) — v4 requires create(content, fileName, path).
Moving or renaming a file
app.files.move(path, newPath) moves or renames a file or directory.
await app.files.move("/version.ts", "/src/version.ts");
Deleting a file or directory
app.files.delete(path) deletes a file or an entire directory.
await app.files.delete("/src/version.ts");