Renaming files

The reference figure and the steps below explain the process of renaming a document in ONLYOFFICE Docs.

Renaming File

  1. The user gives a new name to the document in the document editor.
  2. The document editor informs the document manager about the new name of the document.
  3. The document manager sends the new name of the document to the document storage service where the software integrators rename the document.
  4. The document storage service informs the document editing service about the new name of the document.
  5. The document editing service sends the new name of the document to the document editor of each user.
  6. Now the new name becomes visible to all users.

How this can be done in practice

  1. Create an html file to Open the document.

  2. 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.

    onRequestRename
    function onRequestRename(event) {
      const title = event.data
    }
    
    const docEditor = new DocsAPI.DocEditor("placeholder", {
      events: {
        onRequestRename,
      },
    })
    
  3. 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"
      }
    }
    
  4. 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.

    function onMetaChange(event) {
      const title = event.data.title
    }
    
    const docEditor = new DocsAPI.DocEditor("placeholder", {
      events: {
        onMetaChange,
      },
    })
    

Get Help

  • If you have any questions about ONLYOFFICE Docs, try the FAQ section first.
  • You can request a feature or report a bug by posting an issue on GitHub.
  • You can also ask our developers on ONLYOFFICE forum (registration required).