write

To write text content into a file, use the file/write method:

Copied!
svc=file/write&params={
   "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 Format of the content passed in the content parameter:
0 — text,
1 — hex string,
2 — base64 string.

Response

If the request is completed successfully, an empty response is returned.

Copied!
{} /* empty json */

Otherwise, an error code is returned.

Error codes

Code Description
1 User not authorized.
4 Invalid input parameters.
5 Failed to write the file, for example, because a file with the same name already exists and “writeType”:2 is specified.
7 The item specified in the itemId parameter isn’t found, the storageType value is invalid, or you have no View and download files and Upload and delete files access rights to the item.

If you find a mistake in the text, please select it and press Ctrl+Enter.