public async Task <ObjectResult <object> > DownloadPackage(int packageId, string token) { Uri url = new Uri(ApiUrl + $"download?token={token}&package_id={packageId}"); OnDownloadProgressChanged?.Invoke(0); WebClient webClient = new WebClient(); webClient.DownloadProgressChanged += (sender, e) => { OnDownloadProgressChanged?.Invoke(e.ProgressPercentage); }; string tempFname = Path.GetTempFileName(); await webClient.DownloadFileTaskAsync(url, tempFname); if (ZipTools.IsCompressedData(tempFname)) { return(new ObjectResult <object>(1, "Package succesfully downloaded!", tempFname)); } else { ObjectResult <object> obj = JsonConvert.DeserializeObject <ObjectResult <object> >(File.ReadAllText(tempFname)); obj.code = 0; obj.content = tempFname; return(obj); } }