Skip to content

A high performance, multi-threaded C# file download library.

License

Notifications You must be signed in to change notification settings

puc9/OctaneDownloader

 
 

Repository files navigation

C# CodeQL CodeFactor codebeat badge Codacy Badge NuGet latest version Nuget

alt tag

A high Performance C# file downloader that asyncrounously downloads files as pieces. Made as a faster, more efficent replacement to Microsoft's WebClient.Want to see the library in action? Check out Octane YouTube Extractor

Installation

dotnet add package OctaneEngineCore

Features

  • Multipart Downloading
  • Download Retry
  • Progress
  • Throttling
  • Logging
  • Proxy Support
  • Pause/Resume Support
  • JSON/Microsoft.Extensions.Configuration Support

Usage

private const string Url = "https://plugins.jetbrains.com/files/7973/281233/sonarlint-intellij-7.4.0.60471.zip?updateId=281233&pluginId=7973&family=INTELLIJ";
private static void Main()
{
     //Logging Setup
     var seriLog = new LoggerConfiguration()
          .Enrich.FromLogContext()
          .MinimumLevel.Verbose()
          .WriteTo.File("./OctaneLog.txt")
          .WriteTo.Console(theme: AnsiConsoleTheme.Sixteen)
          .CreateLogger();
     var factory = LoggerFactory.Create(logging => {
          logging.AddSerilog(seriLog);
     });

     //JSON Config Loading
     var builder = new ConfigurationBuilder();
     builder.SetBasePath(Directory.GetCurrentDirectory())
          .AddJsonFile("appsettings.json", true, true);
     var configRoot = builder.Build();
     var config = new OctaneConfiguration(configRoot, factory);
            
     //Find Optimal number of parts
     var optimalNumberOfParts = Engine.GetOptimalNumberOfParts(Url).Result;
     seriLog.Information("Optimal number of parts to download file: {OptimalNumberOfParts}", optimalNumberOfParts);
            
     seriLog.Information("Speed: {Result}", NetworkAnalyzer.GetCurrentNetworkSpeed().Result);
     seriLog.Information("Latency: {Result}", NetworkAnalyzer.GetCurrentNetworkLatency().Result);
     var pauseTokenSource = new PauseTokenSource();
     var cancelTokenSource = new CancellationTokenSource();
            
     var octaneEngine = new Engine(factory, config);
     octaneEngine.DownloadFile(Url, null, pauseTokenSource, cancelTokenSource).Wait(cancelTokenSource.Token);
        

License

The MIT License (MIT)

Copyright (c) 2015 Greg James

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Contributors

GitHub Contributors Image

About

A high performance, multi-threaded C# file download library.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 100.0%