guideIntroduction

# Saving the collaboration data

This guide covers three separate methods of reading the content of a collaboration session to save it to some permanent storage using:

  • The Autosave plugin – a client-side solution, through which the users periodically send the content of the collaboration session to your server.
  • The Cloud Services REST API – a server-side solution, where your server can send a request to Cloud Services Collaboration Server to receive the content of the edited document to store it in your database.
  • Document Storage – a Cloud Services solution, where the document data is permanently saved in the CKEditor Cloud Services server.

# The autosave plugin

While using the autosave plugin, user data is periodically sent to the client’s server, where it can be handled, validated and stored in the database. See the diagram below for the details of the process.

The workflow of the Autosave plugin.

This method, although the simplest to implement, has its drawbacks:

  • There is a race condition issue when many users are working on the same document and you need to ensure that you save the most recent version of the document.
  • The data is coming from an untrusted source (the end-user) and may be manipulated.
  • When opening previously edited documents, the user needs to fetch the content from the database to use it as the initial data.
  • It increases the number of requests and the traffic to your server.
  • It may be slow, especially when a large document is edited by a user with a poor internet connection.

# Export using the Cloud Services REST API

This mechanism, based on the REST API, was introduced as an alternative to the autosave plugin. It improves and simplifies the process of synchronizing the data of the document which is saved in your database.

Using this feature, the responsibility for saving the current document data will be transferred from collaborating users to your server. As a result, it is your server that gets the current content of the document from CKEditor Cloud Services.

Please compare the diagram showing the data workflow to notice the differences:

Data handling in the new solution.

The number of requests is largely reduced — there is just one connection present between the CKEditor Cloud Services server and the client’s server. The whole responsibility of serving and storing the content is handled by server-server connection. The collaborator’s only role is content editing.

# The benefits of using the Cloud Services REST API

  • The user is sure to use the latest version of the document. There is no risk of race condition, data inconsistency or other problems related to document synchronization.
  • Reduced number of requests to your server. Collaborating users no longer need to send the document data in time intervals.
  • Increased communication security. The synchronization process takes place only between your server and the CKEditor Cloud Services server using an encrypted SSL connection and request signatures.
  • The process of saving the document data is independent of the network conditions in which the users work.
  • The content in the collaboration session can be initialized by the client’s server.
  • One export operation means only one document content which allows you to save some storage and get rid of minor changes to the document versions.

Check out the import and export guide for the implementation details.

# Document storage

Cloud Services also offer the document storage feature that allows you to permanently save the document data in CKEditor Cloud Services. In this case, the client-server handling used to store the document data is replaced with Cloud Services server. This is especially convenient for clients that value speed and security. When a user connects to a previously existing document for which a collaboration session has already expired, the document is automatically loaded into a new collaboration session.

# Benefits of the document storage feature

  • Reduced number of requests to your server. Collaborating users no longer need to send the document data in time intervals.
  • Your server is completely excluded from the responsibility of saving the document.
  • The process of saving the document data is independent of the users’ or your server’s network conditions.
  • No need to check whether a collaborative document session currently exists.
  • No need to load the current content of the document in case the collaboration session has expired.
  • No race condition problem when saving the document data.
  • Documents are saved in an encrypted form.
  • It is possible to get or delete documents from the storage or get the documents list via the REST API.

Check out the document storage guide for implementation details.

# Ways of initializing the collaboration session with data

The users will not always start from an empty editor and finish the document in one collaboration session. There is hence the need to initialize the editor with the previously saved versions of content or with some generated templates. Similar to getting the collaboration data, there are few ways to start a new collaboration session with your content:

  • Use the initialData property in the editor configuration – the content passed to this property will be used when the user opens the editor. It will not overwrite the data if the collaboration session already exists.
  • Use Import from the Cloud Services REST API – your server can initialize the content in the collaboration session with a single API call, and then the users will be able to connect to this collaboration session.
  • Use document storage – if you enabled this feature, then opening previously edited documents will be automatically initialized with the saved content.

Refer to the import and export and document storage guides for implementation details.