write
To write text content into a file, use the file/write method:
svc=file/write¶ms={
"itemId":<long>,
"storageType":<uint>,
"path":<text>,
"content":<text>,
"writeType":<uint>,
"contentType":<uint>
}
Parameters
| Parameter | Description |
|---|---|
| itemId | Item ID. |
| storageType | Storage type: 1 — public (all users can see and download files), 2 — protected (only users with access rights can see and download files). |
| path | Relative path from the root folder to the file. |
| content | File content. |
| writeType | Write type: 0 — overwrite the file, 1 — append to the file content, 2 — don’t overwrite if the file exists. |
| contentType | Content type. The content can be returned as: 0 — text, 1 — hex string, 2 — base64 string. |
Response
If the request is completed successfully, an empty response is returned.
{} /* empty json */
Otherwise, an error code is returned.
Error codes
| Code | Description |
|---|---|
| 1 | User not authorized. |
| 4 | Invalid input parameters. |
| 5 | Failed to overwrite the file because a file with the same name already exists and “writeType”:2 is specified. |
| 7 | Insufficient rights to the item specified in the itemId parameter. |