ES2Web.UploadFile
public IEnumerator UploadFile(string path)
Parameters
[table th=”0″]path,”The path of the file we want to upload.”[/table]
Returns
[table th=”0″]IEnumerator,”The IEnumerator for the coroutine.”[/table]
Description
Uploads an entire local file to the server. This method is usefulĀ for easily syncing save data with the cloud.
Note thatĀ to load data from the file, you will need to download the entire file first, and then use ES2Web.SaveToFile to save it as a local file, or use ES2Web’s Load methods to load tags from it.
C#
Upload and Download a local file to and from a server
// Create a local file. ES2.Save(123, "myFile.txt?tag=myInt"); ES2.Save(new float[]{1f,2f,3f}, "myFile.txt?tag=myFloatArray"); // Upload the entire local file to the server. ES2Web web = new ES2Web("https://site.com/ES2.php?webfilename=myFile.txt"); yield return StartCoroutine( web.UploadFile("myFile.txt") ); // Download the file and replace the local file with it. yield return StartCoroutine( web.Download() ); web.SaveToFile("myFile.txt");
JS
Upload and Download a local file to and from a server
// Create a local file. ES2.Save(123, "myFile.txt?tag=myInt"); ES2.Save(new float[]{1f,2f,3f}, "myFile.txt?tag=myFloatArray"); // Upload the entire local file to the server. var web = new ES2Web("https://site.com/ES2.php?webfilename=myFile.txt"); yield return StartCoroutine( web.UploadFile("myFile.txt") ); // Download the file and replace the local file with it. yield return StartCoroutine( web.Download() ); web.SaveToFile("myFile.txt");