Skip to main content
sbx.Files is the *Filesystem sub-object available on every Sandbox instance. All paths must be absolute paths within the sandbox filesystem.

sbx.Files.Read()

Read a file as a UTF-8 string from the sandbox.
string
required
Absolute path inside the sandbox.
string
default:"server default"
Unix user context for file operations. Server defaults to "user" when not specified.
Returns (string, error)

sbx.Files.ReadBytes()

Read a file as raw bytes.
Returns ([]byte, error)

sbx.Files.Write()

Write a UTF-8 string to a file. Creates parent directories automatically.
string
required
Absolute path inside the sandbox.
string
required
Content to write.
Returns (*WriteInfo, error)

sbx.Files.WriteBytes()

Write raw bytes to a file. Uses the binary-safe PUT /files/raw endpoint.
Returns (*WriteInfo, error)

sbx.Files.WriteFiles()

Write multiple files in a single batch request. More efficient than calling Write() in a loop.
Each entry’s Data must be a string. Use WriteBytes for binary data.
[]WriteEntry
required
List of WriteEntry values. Each has Path (string) and Data (string).
Returns error

sbx.Files.List()

List the contents of a directory.
string
required
Absolute path to the directory.
Returns ([]EntryInfo, error)

sbx.Files.Exists()

Check whether a file or directory exists.
Returns (bool, error)

sbx.Files.GetInfo()

Get metadata about a single file or directory.
Returns (*EntryInfo, error)

sbx.Files.Remove()

Remove a file or directory.
Returns error

sbx.Files.Rename()

Rename or move a file or directory.
Returns error

sbx.Files.MakeDir()

Create a directory (including parent directories if needed).
Returns error

sbx.Files.Watch()

Not yet implemented. Returns an error until server-side streaming support is available.
Watch a path for filesystem changes. Will return a *WatchHandle with an events channel.

Data models

EntryInfo

FileType

WriteInfo

WriteEntry


Examples

Upload and execute a script

Batch upload files

Download generated output