ES3Cloud.Sync
Description
Synchronises a local file with the server.
- If the local file is newer than the file on the server, or no file exists on the server:
- The file on the server will be overwritten with the local file.
- If the file on the server is newer than the local file, or no file exists locally:
- The local file will be overwritten with the file on the server.
Note that all parameters are optional.
If no filePath parameter is provided, it will attempt to sync the default file.
If no user parameter is provided, the file will be global to all users.
For more information, see the Uploading and Downloading Files using ES3Cloud guide.
If using the ES3Cloud.Sync method on iOS you will need to declare that you are using File timestamp APIs using code C617
Parameters
filePath | [Optional] The relative or absolute path of the local file we want to synchronise with the server. |
user |
[Optional] The name of the user this file belongs to, if we don't want the file to be global. |
password |
[Optional] The password of the user this file belongs to. |
settings |
[Optional] The settings we want to use to override the default settings. |
Examples
C#
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
// Create a new ES3Cloud object with the URL to our ES3.php file. var cloud = new ES3Cloud("https://www.myserver.com/ES3Cloud.php", "myAPIKey"); // Synchronise a local file with the cloud for a particular user. yield return StartCoroutine(cloud.Sync("myFile.es3", "myUser", "myUsersPassword")); if(cloud.isError) Debug.LogError(cloud.error); // Synchronise another local file, but make it global for all users. yield return StartCoroutine(cloud.Sync("myGlobalFile.es3")); if(cloud.isError) Debug.LogError(cloud.error); |
JS
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
// Create a new ES3Cloud object with the URL to our ES3.php file. var cloud = new ES3Cloud("https://www.myserver.com/ES3Cloud.php", "myAPIKey"); // Synchronise a local file with the cloud for a particular user. yield cloud.Sync("myFile.es3", "myUser", "myUsersPassword"); if(cloud.isError) Debug.LogError(cloud.error); // Synchronise another local file, but make it global for all users. yield cloud.Sync("myGlobalFile.es3"); if(cloud.isError) Debug.LogError(cloud.error); |