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 sets0640; 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_FOUNDunlesscreateDirectoriesistrue, which creates the missing parents with mode0750. A parent path that runs through a regular file answers404 NOT_FOUNDeither way. - A session that does not exist answers
404 SESSION_NOT_FOUND. - Decoded content can be at most
PEEN_MAX_FILE_API_BYTESbytes, 16 MiB by default. Larger content, or content that is not valid base64, answers400 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
- 200
- 400
- 401
- 403
- 404
- 406
- 500
The file was written. The body is its metadata after the write.
Response Headers
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.
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.
The request is invalid. code is VALIDATION_FAILED for a bad parameter, body field, page bound, base64 value or file size, or a body that is not one JSON value or exceeds the body limit, and INVALID_SESSION_ID for a malformed X-Session-ID header.
PEEN_API_TOKEN is set and the request's bearer token is missing or wrong. code is UNAUTHORIZED. A deployment with no token never returns this.
The deployment does not allow what the request names. code is WORKSPACE_NOT_ALLOWED for a workspace outside every workspace root, a workspace file path that is not a clean relative path inside the workspace, or a file operation on the system session; AGENT_SPACE_NOT_ALLOWED for an agent space the deployment does not offer or a move of the system session; and SYSTEM_AGENT_OFF for a system session while PEEN_SYSTEM_AGENT is off.
The session, or the record the request names inside it, does not exist. code is SESSION_NOT_FOUND when no session has the X-Session-ID ID, on every operation. It is NOT_FOUND when the session exists but the record the request names inside it does not, and the message names what is missing, such as job not found. It is WORKSPACE_NOT_FOUND when an opened workspace directory no longer exists.
The request's Accept header allows neither application/json nor */*, and every response is JSON. code is BAD_REQUEST and message is unsupported response representation. Omit Accept or send application/json.
An unexpected server failure. code is INTERNAL_SERVER_ERROR and message is internal server error. The controller log has the details under the response's X-Request-ID.