Renaming files
The reference figure and the steps below explain the process of renaming a document in ONLYOFFICE Document Server.
- The user gives a new name to the document in the document editor.
- The document editor informs the document manager about the new name of the document.
- The document manager sends the new name of the document to the document storage service where the software integrators rename the document.
- The document storage service informs the document editing service about the new name of the document.
- The document editing service sends the new name of the document to the document editor of each user.
- Now the new name becomes visible to all users.
How this can be done in practice
- Create an html file to Open the document.
Specify the event handler for opening the Rename… menu in the configuration script for Document Editor initialization. When the onRequestRename event is called, the new name of the document without extension is sent to the software integrators which rename the document in the document storage service.
var onRequestRename = function(event) {
var title = event.data;
...
};
var docEditor = new DocsAPI.DocEditor("placeholder", {
"events": {
"onRequestRename": onRequestRename,
...
},
...
});
In order to update the name of the document for all collaborative editors, send the request to the document command service, using the meta value for the c parameter:
{
"c": "meta",
"key": "Khirz6zTPdfd7",
"meta": {
"title": "Example Document Title.docx"
}
}
When the name of the document is changed via the meta command, the onMetaChange event must be called in the document editor of each user. This event sends the name of the document in the data.title parameter.
var onMetaChange = function (event) {
var title = event.data.title;
...
};
var docEditor = new DocsAPI.DocEditor("placeholder", {
"events": {
"onMetaChange": onMetaChange,
...
},
...
});