Files
Read, write, and manage files in the sandbox filesystem. All paths are absolute (e.g., /workspace/app.js).
Write content to a file.
await sandbox.writeFile(path: string, content: string, options?: WriteFileOptions): Promise<void>Parameters:
path- Absolute path to the filecontent- Content to writeoptions(optional):encoding- File encoding ("utf-8"or"base64", default:"utf-8")
await sandbox.writeFile("/workspace/app.js", `console.log('Hello!');`);
// Binary dataawait sandbox.writeFile("/tmp/image.png", base64Data, { encoding: "base64" });await sandbox.writeFile('/workspace/app.js', `console.log('Hello!');`);
// Binary dataawait sandbox.writeFile('/tmp/image.png', base64Data, { encoding: 'base64' });Read a file from the sandbox.
const file = await sandbox.readFile(path: string, options?: ReadFileOptions): Promise<FileInfo>