Skip to content

File System

Transfer files between your application and the sandbox using the sandbox API. All file operations use the same bearer token as the rest of the API.

Send a file into the sandbox. Parent directories are created automatically if they do not exist.

const content = Buffer.from('print("hello")')
await sandbox.uploadFile('/workspace/hello.py', content)

Retrieve a file from the sandbox. The response is the raw file bytes.

const bytes = await sandbox.downloadFile('/workspace/output.txt')
console.log(bytes.toString())
await sandbox.uploadFile('/run.sh', Buffer.from('#!/bin/bash\necho hello'))
const result = await sandbox.exec({ command: 'bash /run.sh' })
console.log(result.stdout)
await sandbox.exec({ command: 'python3 -c "import json; json.dump({\'x\': 1}, open(\'/out.json\', \'w\'))"' })
const bytes = await sandbox.downloadFile('/out.json')
const data = JSON.parse(bytes.toString())

File uploads are limited to 256 MB by default. For larger transfers, use External Storage to mount an S3 bucket or NFS share directly into the sandbox.