Hello and thanks for checking this question!
I'm making a WebGL app and I need to download multiple files when the page loads.
Here is my code. It is working perfect for downloading a single file.
What should I change to make it download multiple files?
Any help is appreciated.
Thanks!
IEnumerator DownloadFileCo(string file_name, string decompressPath) { string url = "http://mywebsite.com/uploads/" + file_name + ".zip"; using (UnityWebRequest www = UnityWebRequest.Get(url)) { yield return www.Send(); if (www.isNetworkError || www.isHttpError) { Debug.Log(www.error); } else { string savePath = string.Format("{0}/{1}.zip", Application.persistentDataPath, file_name); System.IO.File.WriteAllBytes(savePath, www.downloadHandler.data); Archiver.Decompress(savePath, decompressPath); Debug.Log("Download complted"); } } } public void DownlodFile() { //downloading test.zip from /uploads folder from server StartCoroutine(DownloadFileCo("test", decompressPath: Application.persistentDataPath)); }
I'm making a WebGL app and I need to download multiple files when the page loads.
Here is my code. It is working perfect for downloading a single file.
What should I change to make it download multiple files?
Any help is appreciated.
Thanks!
IEnumerator DownloadFileCo(string file_name, string decompressPath) { string url = "http://mywebsite.com/uploads/" + file_name + ".zip"; using (UnityWebRequest www = UnityWebRequest.Get(url)) { yield return www.Send(); if (www.isNetworkError || www.isHttpError) { Debug.Log(www.error); } else { string savePath = string.Format("{0}/{1}.zip", Application.persistentDataPath, file_name); System.IO.File.WriteAllBytes(savePath, www.downloadHandler.data); Archiver.Decompress(savePath, decompressPath); Debug.Log("Download complted"); } } } public void DownlodFile() { //downloading test.zip from /uploads folder from server StartCoroutine(DownloadFileCo("test", decompressPath: Application.persistentDataPath)); }