public static string GetBasePlatformUrl(this DownloadUrls urls)
 {
     Debug.Log($"Looking up platform url for {Application.platform}...");
     if (Application.isEditor || Application.platform == RuntimePlatform.Android)
     {
         return(urls.android);
     }
     if (Application.platform == RuntimePlatform.IPhonePlayer)
     {
         return(urls.iphone);
     }
     return(null);
 }
Example #2
0
        private static List <string> DownloadFiles(string downloadFolder, DownloadUrls downloadUrls)
        {
            var concurrentFilesList = new ConcurrentBag <string>();

            Parallel.ForEach(downloadUrls.Urls, (url) => {
                var webRequest    = (HttpWebRequest)WebRequest.Create(url);
                webRequest.Method = "POST";
                using (var webResponse = (HttpWebResponse)webRequest.GetResponse())
                    using (var responseStream = webResponse.GetResponseStream())
                        using (var streamReader = new StreamReader(responseStream)) {
                            //var fileName = webRequest.Headers[HttpRequestHeader.]
                            var fileName    = Path.GetFileName(url);
                            var filePath    = Path.Combine(downloadFolder, fileName);
                            string fileData = streamReader.ReadToEnd();
                            File.WriteAllText(filePath, fileData);
                            concurrentFilesList.Add(filePath);
                        }
            });
            return(concurrentFilesList.ToList());
        }