Last Verified: 2025-01-27
Package:
@hopx-ai/sdk on npm
Overview
TheFiles resource provides file operations for sandboxes. Access it via the files property on a Sandbox instance. All file operations are async and work with both text and binary files.
Access
Methods
read
Read text file contents.
path(string): File path to read
Promise<string> - File contents as string
Example:
readBytes
Read binary file contents.
Promise<Buffer> - File contents as Buffer
write
Write text file.
path(string): File path to writecontent(string): Text contentoptions.mode(string, optional): File permissions
writeBytes
Write binary file.
list
List directory contents.
Promise<EnhancedFileInfo[]> - Array of file/directory information objects
exists
Check if file/directory exists.
Promise<boolean> - true if exists, false otherwise
remove
Remove file or directory.
mkdir
Create directory.
download
Download file (alias for readBytes).
Examples
Example 1: Basic File Operations
Related Classes
- Sandbox - Main sandbox class
- Commands - Command execution resource
- Types - TypeScript type definitions
See Also
- Core Concepts: Files - Learn about file operations
- Sandbox Class - Access files via
sandbox.files
Related
- Python SDK: Files - Python SDK file operations
- Reading Files - Learn about reading files
- Writing Files - Learn about writing files
Next Steps
- Learn about Reading Files to access file contents
- Explore Writing Files to create files
- Review Uploading Files for local file transfers
- CLI File Operations - Use file operations from CLI

