Commands

file write

Write bytes into a Poly file, creating it if needed.

poly file write writes bytes into a Poly file. If the target path doesn't exist it's created; if it exists, its bytes are replaced.

Usage

poly file write <TARGET>

TARGET accepts a local path inside the sync folder or a //-prefixed Poly path — see How it Works for the full reference syntax. The parent folder must already exist; file write never creates it — use mkdir first. Mime type is inferred only when the file is created, not on overwrite.

Flags

FlagDescription
--stdinRead the body from stdin. This is the default; the flag is explicit for clarity. Conflicts with --text.
--text <TEXT>Write this literal text instead of reading stdin. Pass --text "" to truncate the file.
--no-clobberFail instead of replacing bytes if the file already exists.

Examples

# Create a new file from stdin
echo "hello world" | poly file write //Home/notes/hello.txt

# Write literal text directly
poly file write //Home/notes/hello.txt --text "hello world"

# Truncate an existing file
poly file write //Home/notes/hello.txt --text ""

# Pipe a command's output into a new file
poly ls //Home/docs -l | poly file write //Home/notes/listing.txt

# Refuse to overwrite an existing file
poly file write //Home/notes/hello.txt --text "new" --no-clobber
  • file read — read a file's content back out.
  • file update — change metadata (name, tags, rating) without touching bytes.
  • mkdir — create the parent folder first.
  • How it Works — file reference syntax and the local cache.
© Poly Corp. 2026