Esempio n. 1
0
        /// <summary>
        /// Downloads the binary file using the HTTP downloader
        /// </summary>
        /// <param name="url">The URL.</param>
        /// <param name="localFile">The local file to download to</param>
        public void DownloadBinaryFile(string url, string localFile)
        {
            EnsureDirectoryExist(localFile);
            _logger.Debug($"Download {url} to {localFile}");
            var content = _webDownloader.DownloadBinary(url);

            if (content == null)
            {
                _logger.Warn($"No data received, can't save {localFile}");
                return;
            }
            var file = File.OpenWrite(localFile);

            file.Write(content, 0, content.Length);
            file.Close();
        }
Esempio n. 2
0
        public byte[] DownloadBinary(string url, bool noCache = false)
        {
            var data = GetFromCache(url);

            if (data != null && !noCache)
            {
                return(data.ByteData);
            }
            var webData = _webDownloader.DownloadBinary(url);

            if (webData != null)
            {
                _cache.Add(url, new CacheObject(url, webData));
            }
            return(webData);
        }
Esempio n. 3
0
 public byte[] DownloadBinary(string url, bool noCache = false)
 {
     return(_webDownloader.DownloadBinary(url, noCache));
 }