Upload & download files to a web server using ES3 Cloud

Using the MySQL tables and PHP files included with Easy Save 3, you’re able to upload, download, and sync files with a database on a server. This will also allow you to access these files across platforms.

Note that if you just need files to be backed up, Easy Save works with Steam Auto Cloud, Android Auto Backup and Apple iCloud Backup out of the box so ES3Cloud might not be required depending on on what platforms you’re targeting.

  1. Place the ES3Cloud.php file on your server
    • The ES3Cloud.php file is found in the Assets/Plugins/Easy Save 3/Web folder in your project.
  2. Navigate to the file in a web browser
    • i.e. https://www.yourserver.com/ES3Cloud.php
  3. Follow the instructions by entering your database details
    • If your server does not support certain features, you may be asked to manually add the tables to the database, and manually create an ES3Variables.php file.
  4. Take note of the API key you are given when the installation completes
    • This can also be found in the ES3Variables.php file.
  5. You’re ready to use ES3 Cloud from your Unity project

You can synchronize a local file with the server using the ES3Cloud.Sync method:

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

Methods are provided to allow more direct control of the uploading and downloading process.

See the Other Methods section of the ES3Cloud page for more information.

After calling an ES3Cloud coroutine, you should always confirm the request was successful by checking the ES3Cloud.isError variable.

If an error occurred, an error code and error message will be stored in the ES3Cloud.errorCode and ES3Cloud.error variables.

For more information on error codes, see the ES3Cloud.errorCode page.

If your WebGL player and ES3Cloud.php are on the same server, ES3Cloud will work in the exact same way as it does on any other platform.

If your WebGL player is on a different server to your ES3Cloud.php file, WebGL requires that your server has CORS enabled. More information on this can be found in Unity’s WebGL Networking guide.

If using the ES3Cloud.Sync method on iOS you will need to declare that you are using File timestamp APIs using code C617.1 as Sync relies on this functionality in order to check whether the file on the server is newer than the one stored locally. For more information please see Apple’s documentation.

ES3Cloud provides optional user and password parameters, allowing you to store data which is unique to a user.

ES3Cloud does not contain any login system functionality, so you may need to integrate your project with a login system to generate a username and password to the user. See the ‘Integrating with a login system’ section below for more information.

For security reasons, a hash of the username and password are sent to the server rather than the username and password itself. If you wish to send the raw username and password to the server so that you can use them in a custom PHP script, add them as POST variables using the ES3Cloud.AddPOSTField method.

If no username or password is specified, the file is assumed to be global.

To integrate ES3Cloud with a login system you would need to do the following:

  1. After creating your ES3Cloud object, use ES3Cloud.AddPOSTField to add your user’s username and password to the request. E.g.
  2. Modify the ES3Cloud.php file so that immediately after the opening <?php of the file, use $_POST to get the username and password. E.g.
  3. Authenticate this username and password with your login system (contact your login system provider if you require further information regarding this). If the username and password don’t authenticate, call the Error($headerMsg, $msg, $code) method with an appropriate error and a 403 code. E.g.