protected void DownloadAllTempFiles(string url, string downloadDirectoryPath, NetworkUtils.DownloadProgressHandler progressCallback, object callbackParam) { try { LOG.Debug("DownloadAllTempFiles: Attempting to download files from url: {0}", url); string tempZipFile = MakeTempFilePath(); NetworkUtils.DownloadFile(url, tempZipFile); try { _zipHelper.UncompressDirectory(tempZipFile, downloadDirectoryPath, _downloadedContentPassword); } finally { FileUtils.SafeDeleteFile(tempZipFile); } LOG.Debug("DownloadAllTempFiles: Downloaded files from url: {0}", url); } catch (Exception e) { LOG.Error("DownloadAllTempFiles: Failed to download data from url: {0}", e, url); throw; } }
protected string DownloadAllTempFiles(string url, NetworkUtils.DownloadProgressHandler progressCallback, object callbackParam) { string downloadDirectoryPath = Path.Combine(_tempFolderPath, Guid.NewGuid().ToString()); DownloadAllTempFiles(url, downloadDirectoryPath, progressCallback, callbackParam); return(downloadDirectoryPath); }
protected byte[] DownloadData(string url, NetworkUtils.DownloadProgressHandler progressCallback, object callbackParam) { try { LOG.Debug("DownloadData: Attempting to download data from url: {0}", url); byte[] data = NetworkUtils.DownloadData(url, progressCallback, callbackParam); data = _zipHelper.UncompressWithPassword(data, _downloadedContentPassword); LOG.Debug("DownloadData: Downloaded {0} content bytes from url: {0}", data.Length, url); return(data); } catch (Exception e) { LOG.Error("DownloadData: Failed to download data from url: {0}", e, url); throw; } }
protected void DownloadFile(string url, string contentFilePath, NetworkUtils.DownloadProgressHandler progressCallback, object callbackParam) { string tempZipFile = MakeTempFilePath(); try { LOG.Debug("DownloadFile: Attempting to download file from url: {0}", url); NetworkUtils.DownloadFile(url, tempZipFile, progressCallback, callbackParam); if (_zipHelper.IsCompressed(tempZipFile)) { _zipHelper.UncompressWithPassword(tempZipFile, contentFilePath, _downloadedContentPassword); } else { File.Move(tempZipFile, contentFilePath); tempZipFile = null; } LOG.Debug("DownloadFile: Downloaded {0} file bytes from url: {0}", new FileInfo(contentFilePath).Length.ToString(), url); } catch (Exception e) { LOG.Error("DownloadFile: Failed to download data from url: {0}", e, url); throw; } finally { if (tempZipFile != null) { FileUtils.SafeDeleteFile(tempZipFile); } } }