/files/{user}/content
0.1.0Unchanged since publicationWrite the entire contents of a file
filesallFor a raw upload, use Content-Type application/octet-stream, supply path in the query, and set Content-Length to the exact byte count. Use 0 for an empty file. The API returns 411 if Content-Length is missing. It checks the declared length against files.upload_limit_mb before reading the body and returns 413 with a message directing you to SFTP if the length exceeds the limit. The API streams the upload and puts it in place only after receiving all declared bytes. If the upload ends early, the API returns 400 and any existing file stays in place. The API returns 507 if there is insufficient disk space or the upload exceeds the disk quota.
For an editor save or other small write, use Content-Type application/json and supply path and base64-encoded content in the body. The API returns 400 if content contains characters outside the standard base64 alphabet, padding, and line breaks. The same files.upload_limit_mb ceiling applies to the decoded file size. The API returns 403 if it cannot open the file for writing and 500 if writing or closing the file fails.
Set create_only in the query for a raw upload or in the body for JSON. When true, the API returns 201 for a new file or 409 if the destination exists. When false or omitted, the API returns 200 on success. The write uses the customer's permissions and refuses to follow symbolic links. New files get mode 0644, and replacements retain the existing mode.
As a command
Run as root on the serverParameters
userpath ·UsernameRequiredpathquery ·HomePathcreate_onlyquery ·booleancontentstringRequiredpathHomePathRequiredcreate_onlybooleanExample
See the API overview for how to set $API and $TOKEN.curl -sS -X PUT "$API/files/alice/content?path=public_html/index.php&create_only=1" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/octet-stream" \
--data-binary @file
curl -sS -X PUT "$API/files/alice/content" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"content": "text",
"create_only": true,
"path": "public_html/index.php"
}'200 OK{
"file": {
"inside": true,
"mode": "text",
"modified": "text",
"name": "alice",
"owner": "text",
"path": "public_html/index.php",
"size": 1,
"target": "https://example.com/new",
"target_type": "dir",
"text": true,
"type": "dir"
}
}Errors
17 errors, each a status and a sentence400--content-stdin is required: the content, base64, comes on standard input400--length is required with --bytes-stdin: how many bytes come400--path is required400--user is required400<name> is an administrator: administrators have no home400<what> climbs out of the home with ..400<what> has a name over 255 characters400<what> holds a control character400<what> is required400<what> is too long400<what> must start with /, which is the home400Invalid boolean400Invalid username: 2 to 32 lowercase letters, digits or underscores, starting with a letter400Username '<value>' is reserved400content must be base64400path is required: the file goes up with its path in the query401Authentication requiredurbestack.com/docs/api/put-files-user-content/