Skip to content

bhatti file write

Write a file into a sandbox. Reads bytes from stdin and writes them to the absolute <path> inside the sandbox.

bhatti file write <sandbox> <path>

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).

Terminal window
echo 'console.log("hello")' | bhatti file write dev /workspace/app.js
Terminal window
# From a local file
bhatti file write dev /workspace/config.json < ./config.json
Terminal window
# Generate and write inline
date | bhatti file write dev /tmp/last-deploy.txt
Terminal window
# Set executable bit via the API directly
local_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.sh

This command takes only global flags. See Global flags for --url, --token, --json, --timing, --data-dir.