Save copy as or Rename

Hallo everybody,

we are integrating OnlyOffice 6.3 into our application and we’re using the docker version (Linux) of the Community edition.

We started using the Python Example (using it as a service) but some features are hard to implement due to some lacks of instructions: for example, it is unclear to us how to fire the event “onRequestSaveAs” which should allow the user to set up a new name for the current document under editing…

Inside the Python Example folder there is a sort of “commander” (actions.py), a set of I/O methods which exchange information between the underlying services (Document Manager, Document Storage Services and so on) through http requests.

Moreover there are a couple of templates (index.html and editor.html) which hold a set of commands and events that gives instructions to the DOM (Document Object Model).

Putting the correct event inside the configuration section (editor.html):
config.events = {

‘onRequestSaveAs’: onRequestSaveAs,

};

and writing the relative function:
var onRequestSaveAs = function(event) {
var title = event.data.title;
var url = event.data.url;
docEditor.showMessage(‘onRequestSaveAs - title:’+title+’\nurl:’+url);

};

we can’t see the message/tooltip (set up by docEditor.showMessage); even if we replace “docEditor.showMessage” with a standard javascript command “alert(‘title:’+title)” the is no result shown (so the function is not fired)

In a different case, using this configuration:
config.events = {
‘onRequestRename’: onRequestRename,
};

and the corresponding function:
var onRequestRename = function(event) {
var title = event.data;
docEditor.showMessage(‘onRequestRename - title:’+title);
};

We’re able to show correctly the tooltip on the screen but we can’t figure out HOW to proceed further to effectively change the name of the file under editing (it seems that none of the available API methods could be applied to accomplish the “rename” requirement).

Can anybody help us to locate the correct way to create the actual interaction between the DOM javascript methods and the service ones (those in Python)?

Thank you in advance

Hello, please note that current Document Server is 6.4.2. We strongly recommend using only the latest Document Server versions as they contain bugfixes and functionality enhancements.

Have you looked at these articles?
https://api.onlyoffice.com/editors/rename
https://api.onlyoffice.com/editors/faq/renaming#renaming_2

Hallo Carl and thank you for your prompt answer.

Of course, prior to create a forum post asking for an help, we’ve thoroughly read all the documents you suggested (and a lot more)!

Did you read with attention our request? It covers not only one but TWO different issues for which the solution is not so easy to identify.

Hello, I also use the python example, but after modifying the name, refresh it and it becomes the original name again. Do I need to use python to rename the hist folder and files on the server?

Hello @zgp
Please provide us with details.
Do you use python example as is? I mean that these examples are needed for tests only: ONLYOFFICE Api Documentation - Language-specific examples
Please pay attention to this title to rename a file: ONLYOFFICE Api Documentation - Renaming Files

Are there an update on how to add the ‘onRequestSaveAs’ function? I have followed on how to add the event through ONLYOFFICE Api Documentation - Config

image

A request did came through as an output as so (I am only allowed for one image):

OnRequestSaveAs - tittle:
fileType:pdf
Click to close the tip

There is no callback as I am not too sure how to implement it as it is quite confusing. And I do not know if the status should be under force save or meta change? Any help would be much appreciated.

Hello @m1ll10n,

Feel free to install one of our integration examples: ONLYOFFICE Api Documentation - Language-specific examples

The onRequestSaveAs event is implemented there so you can check how it works.