private static async Task <bool> DownloadBundle(PatchReport patchReport, BundleData bundleData) { string url = $"{patchReport.ChannelData.URL}/{patchReport.ChannelData.Build}/{bundleData.Version}/{bundleData.Name}"; Debug.Log($"Downloading Bundle:'{url}'"); UnityWebRequest request = await FinalPatchUtility.WebRequestGet(url); if (request == null) { return(false); } //Save string path = FinalPatchUtility.GetPersistentBundlePath(bundleData.Name); string saveDirectory = Path.GetDirectoryName(path); if (!Directory.Exists(saveDirectory)) { Directory.CreateDirectory(saveDirectory); } using (FileStream fs = new FileStream(path, FileMode.Create, FileAccess.Write)) { fs.Write(request.downloadHandler.data, 0, request.downloadHandler.data.Length); } patchReport.PatchedSize += bundleData.Size; patchReport.ClientData.UpdateBundle(bundleData.Name); return(true); }
public static async Task <PatchData> DownloadFromUrl(string url) { UnityWebRequest request = await FinalPatchUtility.WebRequestGet(url); if (request == null) { return(null); } try { PatchData patchData = null; using (MemoryStream ms = new MemoryStream(request.downloadHandler.data)) { XmlSerializer serializer = new XmlSerializer(typeof(PatchData)); patchData = serializer.Deserialize(ms) as PatchData; } return(patchData); } catch (Exception e) { Debug.LogException(e); return(null); } }
private static async Task <DeployData> DownloadDeployData() { UnityWebRequest request = await FinalPatchUtility.WebRequestGet(s_deployDataUrl); if (request == null) { return(null); } try { using (MemoryStream ms = new MemoryStream(request.downloadHandler.data)) { XmlSerializer serializer = new XmlSerializer(typeof(DeployData)); return(serializer.Deserialize(ms) as DeployData); } } catch (Exception e) { Debug.LogException(e); return(null); } }