SandboxFs
Filesystem handle for a running sandbox. Obtained viasb.fs(). All operations go through the same host-guest channel as command execution - no SSH, no network involved. For bulk file operations, consider using volumes instead.
copy()
| Name | Type | Description |
|---|---|---|
| from | string | Source path |
| to | string | Destination path |
copyFromHost()
| Name | Type | Description |
|---|---|---|
| hostPath | string | Path on the host filesystem |
| guestPath | string | Destination path inside the sandbox |
copyToHost()
| Name | Type | Description |
|---|---|---|
| guestPath | string | Path inside the sandbox |
| hostPath | string | Destination path on the host |
exists()
| Name | Type | Description |
|---|---|---|
| path | string | Absolute path inside the guest |
| Type | Description |
|---|---|
boolean | true if the path exists |
list()
| Name | Type | Description |
|---|---|---|
| path | string | Absolute directory path inside the guest |
| Type | Description |
|---|---|
Array<FsEntry> | Directory entries |
mkdir()
| Name | Type | Description |
|---|---|---|
| path | string | Absolute directory path |
read()
| Name | Type | Description |
|---|---|---|
| path | string | Absolute path inside the guest (e.g. "/app/config.json") |
| Type | Description |
|---|---|
Buffer | File contents as raw bytes |
readStream()
| Name | Type | Description |
|---|---|---|
| path | string | Absolute path inside the guest |
| Type | Description |
|---|---|
FsReadStream | Async stream that yields chunks of file data |
readString()
| Name | Type | Description |
|---|---|---|
| path | string | Absolute path inside the guest |
| Type | Description |
|---|---|
string | File contents as a string |
remove()
| Name | Type | Description |
|---|---|---|
| path | string | Absolute file path |
removeDir()
| Name | Type | Description |
|---|---|---|
| path | string | Absolute directory path |
rename()
| Name | Type | Description |
|---|---|---|
| from | string | Current path |
| to | string | New path |
stat()
| Name | Type | Description |
|---|---|---|
| path | string | Absolute path inside the guest |
| Type | Description |
|---|---|
FsMetadata | File metadata |
write()
| Name | Type | Description |
|---|---|---|
| path | string | Absolute path inside the guest |
| data | Buffer | File content |
Types
FsEntry
Metadata for a single directory entry, returned bylist().
| Field | Type | Description |
|---|---|---|
| kind | FsEntryKind | Type of entry |
| mode | number | Unix permission bits |
| modified? | number | Last modified timestamp (ms since epoch) |
| path | string | File path |
| size | number | File size in bytes |
FsEntryKind
| Value | Description |
|---|---|
'directory' | Directory |
'file' | Regular file |
'other' | Other entry type |
'symlink' | Symbolic link |
FsMetadata
Detailed file metadata, returned bystat().
| Field | Type | Description |
|---|---|---|
| created? | number | Creation timestamp (ms since epoch) |
| kind | FsEntryKind | Type of entry |
| mode | number | Unix permission bits |
| modified? | number | Last modified timestamp (ms since epoch) |
| readonly | boolean | Whether the file is read-only |
| size | number | File size in bytes |
FsReadStream
Async stream for reading a file in chunks. Obtained viareadStream().
| Method | Returns | Description |
|---|---|---|
| [Symbol.asyncIterator] | AsyncGenerator<Buffer> | Use with for await...of |
| recv() | Promise<Buffer | null> | Receive the next chunk. Returns null when the file has been fully read. |