bhatti file write
Write a file into a sandbox. Reads bytes from stdin and writes them to the absolute <path> inside the sandbox.
Synopsis
Section titled “Synopsis”bhatti file write <sandbox> <path>
Description
Section titled “Description”Writes are atomic — the guest agent writes to a temp file, fsyncs it, then renames it over the target. Concurrent readers never see partial content.
Writes are capped at 100 MB per request. For larger files, split into chunks or attach a persistent volume instead.
The CLI doesn’t expose --mode for setting the file permissions (defaults to 0644). The underlying API endpoint accepts a mode=0755 query parameter — use it directly when you need to set a specific mode (e.g. 0700 for keys, 0755 for executables).
Examples
Section titled “Examples”echo 'console.log("hello")' | bhatti file write dev /workspace/app.js# From a local filebhatti file write dev /workspace/config.json < ./config.json# Generate and write inlinedate | bhatti file write dev /tmp/last-deploy.txt# Set executable bit via the API directlylocal_token="$BHATTI_TOKEN"curl -X PUT "http://localhost:8080/sandboxes/dev/files?path=/usr/local/bin/run.sh&mode=0755" \ -H "Authorization: Bearer $local_token" \ --data-binary @./run.shOptions
Section titled “Options”This command takes only global flags. See Global flags for --url, --token, --json, --timing, --data-dir.
See also
Section titled “See also”bhatti file read— opposite directionbhatti create --file local:guest— inject a file at boot, no separate write call- API:
PUT /sandboxes/:id/files