Overview
The SDK provides file operations for reading and writing both text and binary content inside sandboxes. All operations use absolute paths.Size limits
- Max write size: 10 MB per file (enforced by SDK)
- For larger files, consider streaming from your app or hosting assets externally
Writing files
Text files
Binary files
Write binary data usingArrayBuffer or Uint8Array:
Reading files
Text files
Binary files
Common patterns
Upload and process
Generate and download
Multi-file operations
Implementation details
- Files are transferred via base64 encoding over the exec API
- Large files are chunked automatically (100KB chunks)
- Absolute paths are required (e.g.,
/tmp/file.txt, notfile.txt) - The SDK uses
catfor reads andprintf | base64 -dfor writes
Error handling
Best practices
Always use absolute paths
File operations require absolute paths starting with/:
Specify encoding for binary files
Always useencoding: "binary" when working with non-text files:
Other best practices
- Check size limits: Ensure files are under 10 MB before writing
- Batch operations: Use
Promise.all()for multiple file operations - Handle errors: Wrap file operations in try-catch blocks
- Clean up: Remove temporary files when done to save space