Ah, I think I misunderstood your question since we discussed about WOPI features here (but not about ‘interface’, that confused me a little bit).
We are still working to improve WOPI (I remember about Forcesave feature for WOPI).
I will notify you when we have something to share.
Sorry I thought interface is clear in this context:
WOPI = Web Application Open Platform Interface
I now opened a issue on Github in parallel: https://github.com/ONLYOFFICE/DocumentServer/issues/1884
Undrerstood, but please do not post the same question in the different communication channels. We are working to improve WOPI.
Described issue is related to lack of forcesave feature on the WOPI, we discussed it earlier and we are working to improve WOPI it and I mentioned workaround solution (usage API: ONLYOFFICE Api Documentation - Command service).
When we have any news about desired scenario (user can save a file during editing session), I will update this thread.
Hi,
are there any news regarding this issue? From the Change log of the releases 7.2.0, 7.2.1 it does not seem so :-/
Hello @rsoika
Please accept our apologies for the length of situation. There’re a lot of tasks which we want to implement to increase user experience. One of them is mentioned in this thread (internal tracksystem number - 58764, Forcesave feature for WOPI) We are still working on it.
I will notify you when we have any news.
Hello
Command service uses a “key” as identifier of the file. But with WOPI there is only file_id. What key can we use with a command if the file was opened in OnlyOffice by WOPI?
And can we call Command service from WOPI Server?
Hello @Vladimir
There’s no possibility of sending requests to the Command Service through WOPI. You need to use Usage API to achieve it.
These are the different protocols with different logic of work, for example, WOPI doesn’t have ‘key’ parameter.
Hello, @Alexandre
What about a workaround solution with Command service which you mentioned earlier?
- The commands work through the API, so in addition to the WOPI, we also have to implement a significant part of the API, namely a callback handler, etc?
- Command service uses a “key” as identifier of the file. But with WOPI there is only file_id. What key can we use with a command if the file was opened in OnlyOffice by WOPI? document.key = file_id ?
- Instead of a sequence of three requests between the WOPI server and the client (host-> office/command → host/callback → ofiice), is it possible to get by with one request that will immediately receive the contents of the file from the WOPI client (OnlyOffice)?
Hello @Vladimir
Sorry for the late reply.
As I mentioned before, there’s no way of sending requests to Command service in the WOPI.
- The commands work through the API, so in addition to the WOPI, we also have to implement a significant part of the API, namely a callback handler, etc?
That’s right.
The main point is if you are going to use Command service, you have to implement the Document server integration to your storage through usage API. it includes document.key generation on your side which is used in most API requests: https://api.onlyoffice.com/editors/config/document#key
Command service uses a “key” as identifier of the file. But with WOPI there is only file_id. What key can we use with a command if the file was opened in OnlyOffice by WOPI? document.key = file_id ?
No, there’s no way of using WOPI parameters in the usage API requests. document.key ≠file_id. There are the different protocols.
Instead of a sequence of three requests between the WOPI server and the client (host-> office/command → host/callback → ofiice), is it possible to get by with one request that will immediately receive the contents of the file from the WOPI client (OnlyOffice)?
I’m not sure that understand this scenario right. Could you please describe the usage scenario as detailed as possible?
Hello, @Alexandre
We tried a workaround solution for WOPI forcesave with Command service which you mentioned earlier.
We opened a file with WOPI by it’s file_id, edited it and then send a command forcesave with the document.key=file_id.
When processing the command request OnlyOffice Docs makes a WOPI PutFile request and the edited file is saved to the storage.
So, the workaround looks fine.
Maybe there are any unsolicited side effects from this method?
Hello @Vladimir ,
maybe you can post an example code how you trigger this command service. I was not able to figure out how to do this.
Hello @rsoika, I’m from @Vladimir team.
We use additional API command forceSave with WOPI:
- WOPI API is partially implemented, namely the functions: CheckFileInfo, GetFile, PutFile and Lock
- Open file in hostPage.
2.1. actionUrl has the structure:{suitable host from discovery}?wopisrc={host:port WOPI server}/wopi/files/{file_id}. Example:
http://localhost/hosting/wopi/word/edit?wopisrc=http://testWOPI:4000/wopi/files/1.docx_457521443
2.2. token - in the test application we don’t perform validation, so a random URI-safe string
2.3 tokenTtl - current time in ms + 10 hours as ms - Implemented a REST POST request forceSave. Example on java
public String forceSave(final String fileId) {
try {
String content = createJsonSave(fileId); // generate request body
HttpRequest httpRequest = HttpRequest.newBuilder()
.uri(new URI(docserviceHost + "/coauthoring/CommandService.ashx")) // set URI command service, example: http://localhost/coauthoring/CommandService.ashx
.header("Content-Type", "application/json") // set Content-Type
.POST(HttpRequest.BodyPublishers.ofString(content)) // add request body
.build();
HttpResponse<String> response = HttpClient.newBuilder().version(HttpClient.Version.HTTP_1_1).build().send(httpRequest, HttpResponse.BodyHandlers.ofString()); // send request
return response.body(); // response forceSave
} catch (URISyntaxException | IOException | InterruptedException e) {
throw new RuntimeException(e);
}
}
/**
* Create request body
*/
private String createJsonSave(String fileId) {
Map<String, Object> jsonStringMap = new HashMap<>();
jsonStringMap.put("c", "forcesave"); // command name
jsonStringMap.put("key", fileId); // WOPI file_id, for the file opened in step 2
jsonStringMap.put("token", jwtManager.createToken(jsonStringMap)); // creating jwt as for API request
return JSONObject.toJSONString(jsonStringMap);
}
- Change document opened in hostPage (step 2)
- Call the forceSave method (step 3), passing the file_id WOPI of the document open in hostPage
- DocumentServer call REST method PutFile on WOPI server
P.S. Sorry, I can’t attach links to documentation due to restrictions for new users, I highlighted documentation in italics
Hello @AlexB and @Vladimir
Thank you for the detailed guide of your workaround solution, we are looking into it.
The provided workaround solution looks good. However, please bear in mind that this isn’t ‘clicking on the Save button’ scenario. As for the implementation of the ForceSave scenario for the button, we are still working on it and I will update this thread when we have something to share.
Hello, @Alexandre
А couple more questions about the “forcesave” command:
-
If a request to the command service with forcesave command returned “error”: 0, does this mean that the save is already guaranteed to have happened? Couldn’t it then happen asynchronously and therefore delayed, especially under high loads?
-
When the user quickly changes something in the edited document in OnlyOffice, the save button is active in the top panel of the editor. But if the user pauses for a few seconds, it is deactivated. While the button is active, the edits made by the user have not yet been transferred to the OnlyOffice server?
The experiment shows that if we call the forcesave command to the OnlyOffice server at the moment when user starts editing and save button activated, we can get a response that there were no changes, there is nothing to save. How can we ensure that the forcesave command saves all the latest changes?
Hello @Vladimir
- If a request to the command service with forcesave command returned “error”: 0, does this mean that the save is already guaranteed to have happened? Couldn’t it then happen asynchronously and therefore delayed, especially under high loads?
The ‘error’:0 means that save process has started successfully. This process will finish when the request to the callbackUrl arrives.
When the user quickly changes something in the edited document in OnlyOffice, the save button is active in the top panel of the editor. But if the user pauses for a few seconds, it is deactivated. While the button is active, the edits made by the user have not yet been transferred to the OnlyOffice server?
The experiment shows that if we call the forcesave command to the OnlyOffice server at the moment when user starts editing and save button activated, we can get a response that there were no changes, there is nothing to save. How can we ensure that the forcesave command saves all the latest changes?
In the bottom of editor interface, a pop-up message ‘All changes saved’ appears constantly. That message means that changes have been passed to Document server cache\database. In your described scenario, a user has started editing and changes still haven’t passed from client to Document server. Meanwhile, at this very moment you have run ForceSave command, but haven’t received any changes to save.
This is expected result since in this very moment Document server didn’t get any new changes from the client yet. Please clarify what guarantees are you lookin for? I mean, do you need to check that changes have come to Document server or something else?
Hello, @Alexandre
1)
But on the Forcesave command on the Document Server integrated with WOPI, it calls the PutFile method instead of callbackUrl. Does this process also run asynchronously?
2)
Yes exactly. Is it possible to check in the client’s host page that the OnlyOffice editor has saved all the latest edits?
Hello @Vladimir
But on the Forcesave command on the Document Server integrated with WOPI, it calls the PutFile method instead of callbackUrl. Does this process also run asynchronously?
Yes, for WOPI the PutFile method will also be called asynchronously without binding to the response ‘error’: 0.
Yes exactly. Is it possible to check in the client’s host page that the OnlyOffice editor has saved all the latest edits?
It seems that you need this event: ONLYOFFICE Api Documentation - Config
and with the parameter: {“data” : false} when the current user’s changes are sent to the document editing service .
Please clarify if I misunderstood your scenario.
Thank you, @Alexandre
Yes, this is exactly the scenario, but with integration via WOPI. In this case, events from the API are not working? How to do the same in WOPI mode?