Filesystem module provides full file I/O within a sandbox. Access it via sandbox.files.
Reading Files
sandbox.files.read(path)
Reads a file as a UTF-8 string.
Absolute path to the file.
Promise<string>
sandbox.files.readBytes(path)
Reads a file as raw bytes.
Absolute path to the file.
Promise<Uint8Array>
Writing Files
sandbox.files.write(path, content)
Writes a string or binary content to a file. Creates parent directories if needed.
Absolute path to the file.
File content to write.
Promise<void>
Listing Directories
sandbox.files.list(path?)
Lists the contents of a directory.
Directory path to list.
Promise<EntryInfo[]>
EntryInfo
| Field | Type | Description |
|---|---|---|
name | string | File or directory name |
isDir | boolean | true if this entry is a directory |
path | string | Full path to the entry |
size | number | Size in bytes (0 for directories) |
Managing Files and Directories
sandbox.files.makeDir(path)
Creates a directory and any necessary parent directories.
Directory path to create.
Promise<void>
sandbox.files.remove(path)
Deletes a file or directory.
Path to remove.
Promise<void>
sandbox.files.exists(path)
Checks whether a file or directory exists.
Path to check.
Promise<boolean>