Skip to content

Read, write, and manage files in the sandbox filesystem. All paths are absolute (e.g., /workspace/app.js).

Methods

writeFile()

Write content to a file.

TypeScript
await sandbox.writeFile(path: string, content: string, options?: WriteFileOptions): Promise<void>

Parameters:

  • path - Absolute path to the file
  • content - Content to write
  • options (optional):
    • encoding - File encoding ("utf-8" or "base64", default: "utf-8")
JavaScript
await sandbox.writeFile("/workspace/app.js", `console.log('Hello!');`);
// Binary data
await sandbox.writeFile("/tmp/image.png", base64Data, { encoding: "base64" });

readFile()

Read a file from the sandbox.

TypeScript
const file = await sandbox.readFile(path: string, options?: ReadFileOptions): Promise<FileInfo>