Skip to main content

Write a workspace file atomically

PUT 

/session/files/content

Creates or replaces one regular file in the session's workspace with the decoded bytes, and returns the written file's metadata. Peen writes a temporary file in the same directory and renames it into place, so a reader sees either the old content or the new content, never a partial file.

  • A new file gets mode 0640. Replacing a file also sets 0640; its earlier permissions are not kept.
  • When the path is a symbolic link to a regular file inside the workspace, the link's target is replaced.
  • A path that is an existing directory or another non-regular file answers 400 VALIDATION_FAILED.
  • A missing parent directory answers 404 NOT_FOUND unless createDirectories is true, which creates the missing parents with mode 0750. A parent path that runs through a regular file answers 404 NOT_FOUND either way.
  • A session that does not exist answers 404 SESSION_NOT_FOUND.
  • Decoded content can be at most PEEN_MAX_FILE_API_BYTES bytes, 16 MiB by default. Larger content, or content that is not valid base64, answers 400 VALIDATION_FAILED. The request body limit for this operation is the base64 length of that maximum plus 64 KiB.
  • There is no conditional write: the last write wins.
  • The path follows the rules of GET /session/files.

Request​

Responses​

The file was written. The body is its metadata after the write.

Response Headers
    X-Session-ID

    The session this response belongs to. For session-scoped requests it echoes the X-Session-ID request header; for POST /sessions/open and POST /sessions/system it is the session that was opened or created.

    X-Request-ID

    The request's correlation ID. When the request carried an X-Request-ID header holding a UUID, Peen echoes it; otherwise Peen generates a new UUID. The controller log records the same value for this request.