Downloader 1.9.7

Fast and reliable multipart downloader with asynchronous progress events for .NET

Install-Package Downloader -Version 1.9.7
dotnet add package Downloader --version 1.9.7
<PackageReference Include="Downloader" Version="1.9.7" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Downloader --version 1.9.7
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Downloader Build and Test
Build Status
NuGet
NuGet
CodeFactor

Downloader

:rocket: Fast and reliable multipart downloader with .Net Core 3.1+ supprting :rocket:

Downloader is a modern, fluent, asynchronous, testable and portable library for .NET. This is a multipart downloader with asynchronous progress events.
This library written in .Net Standard 2 and you can add that in your .Net Core or .Net Framework projects.

Sample Console Application

sample-project

How to use

Get it on NuGet:

PM> Install-Package Downloader

Or via the .NET Core command line interface:

dotnet add package Downloader

Create your custom configuration:

var downloadOpt = new DownloadConfiguration()
{
    AllowedHeadRequest = false, // Can fetch file size by HEAD request or must be used GET method to support host
    MaxTryAgainOnFailover = int.MaxValue, // the maximum number of times to fail.
    ParallelDownload = true, // download parts of file as parallel or notm default value is false
    ChunkCount = 8, // file parts to download, default value is 1
    Timeout = 1000, // timeout (millisecond) per stream block reader, default valuse is 1000
    OnTheFlyDownload = false, // caching in-memory or not? default valuse is true
    BufferBlockSize = 10240, // usually, hosts support max to 8000 bytes, default valuse is 8000
    MaximumBytesPerSecond = 1024 * 1024, // download speed limited to 1MB/s, default valuse is zero or unlimited
    TempDirectory = "C:\\temp", // Set the temp path for buffering chunk files, the default path is Path.GetTempPath().
    RequestConfiguration = // config and customize request headers
    {
        Accept = "*/*",
        UserAgent = $"DownloaderSample/{Assembly.GetExecutingAssembly().GetName().Version.ToString(3)}",
        ProtocolVersion = HttpVersion.Version11,
        AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate,
        KeepAlive = false,
        UseDefaultCredentials = false
    }
};

So, declare download service instance per download and pass config:

var downloader = new DownloadService(downloadOpt);

Then handle download progress and completed events:

downloader.DownloadProgressChanged += OnDownloadProgressChanged;
downloader.ChunkDownloadProgressChanged += OnChunkDownloadProgressChanged;
downloader.DownloadFileCompleted += OnDownloadFileCompleted;    

The ‍DownloadService class has a property called Package that stores each step of the download. You must call the CancelAsync method to stop or pause the download, and if you continue again, you must call the same DownloadFileAsync function with the Package parameter to continue your download!
For example:

Start the download asynchronously and keep package file:

var file = @"Your_Path\fileName.zip";
var url = @"https://file-examples.com/fileName.zip";
// To resume from last download, keep downloader.Package object
var pack = downloader.Package; 
await downloader.DownloadFileAsync(url, file);

Stop or Pause Download:

downloader.CancelAsync(); 

Resume Download:

await downloader.DownloadFileAsync(pack); 

So that you can even save your large downloads with a very small amount in the Package and after restarting the program, restore it again and start continuing your download. In fact, the packages are your instant download snapshots. If your download config has OnTheFlyDownload, the downloaded bytes ​​will be stored in the package itself, but otherwise, only the address of the downloaded files will be included and you can resume it whenever you like.
For more detail see StopResumeOnTheFlyDownloadTest method

Note: for complete sample see Downloader.Sample project from this repository.

Features at a glance

  • Download files async and non-blocking.
  • Cross-platform library to download any files with any size.
  • Get real-time progress info of each block.
  • Download file multipart as parallel.
  • Handle any client-side or server-side exception none-stopping the downloads.
  • Config your ChunkCount to define the parts count of the download file.
  • Download file multipart as in-memory or in-temp files cache mode.
  • Store download package object to resume the download when you want.
  • Get download speed or progress percentage in each progress event.
  • Get download progress events per chunk downloads
  • Stop and Resume your downloads with package object
  • Set a speed limit on downloads

Downloader Build and Test
Build Status
NuGet
NuGet
CodeFactor

Downloader

:rocket: Fast and reliable multipart downloader with .Net Core 3.1+ supprting :rocket:

Downloader is a modern, fluent, asynchronous, testable and portable library for .NET. This is a multipart downloader with asynchronous progress events.
This library written in .Net Standard 2 and you can add that in your .Net Core or .Net Framework projects.

Sample Console Application

sample-project

How to use

Get it on NuGet:

PM> Install-Package Downloader

Or via the .NET Core command line interface:

dotnet add package Downloader

Create your custom configuration:

var downloadOpt = new DownloadConfiguration()
{
    AllowedHeadRequest = false, // Can fetch file size by HEAD request or must be used GET method to support host
    MaxTryAgainOnFailover = int.MaxValue, // the maximum number of times to fail.
    ParallelDownload = true, // download parts of file as parallel or notm default value is false
    ChunkCount = 8, // file parts to download, default value is 1
    Timeout = 1000, // timeout (millisecond) per stream block reader, default valuse is 1000
    OnTheFlyDownload = false, // caching in-memory or not? default valuse is true
    BufferBlockSize = 10240, // usually, hosts support max to 8000 bytes, default valuse is 8000
    MaximumBytesPerSecond = 1024 * 1024, // download speed limited to 1MB/s, default valuse is zero or unlimited
    TempDirectory = "C:\\temp", // Set the temp path for buffering chunk files, the default path is Path.GetTempPath().
    RequestConfiguration = // config and customize request headers
    {
        Accept = "*/*",
        UserAgent = $"DownloaderSample/{Assembly.GetExecutingAssembly().GetName().Version.ToString(3)}",
        ProtocolVersion = HttpVersion.Version11,
        AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate,
        KeepAlive = false,
        UseDefaultCredentials = false
    }
};

So, declare download service instance per download and pass config:

var downloader = new DownloadService(downloadOpt);

Then handle download progress and completed events:

downloader.DownloadProgressChanged += OnDownloadProgressChanged;
downloader.ChunkDownloadProgressChanged += OnChunkDownloadProgressChanged;
downloader.DownloadFileCompleted += OnDownloadFileCompleted;    

The ‍DownloadService class has a property called Package that stores each step of the download. You must call the CancelAsync method to stop or pause the download, and if you continue again, you must call the same DownloadFileAsync function with the Package parameter to continue your download!
For example:

Start the download asynchronously and keep package file:

var file = @"Your_Path\fileName.zip";
var url = @"https://file-examples.com/fileName.zip";
// To resume from last download, keep downloader.Package object
var pack = downloader.Package; 
await downloader.DownloadFileAsync(url, file);

Stop or Pause Download:

downloader.CancelAsync(); 

Resume Download:

await downloader.DownloadFileAsync(pack); 

So that you can even save your large downloads with a very small amount in the Package and after restarting the program, restore it again and start continuing your download. In fact, the packages are your instant download snapshots. If your download config has OnTheFlyDownload, the downloaded bytes ​​will be stored in the package itself, but otherwise, only the address of the downloaded files will be included and you can resume it whenever you like.
For more detail see StopResumeOnTheFlyDownloadTest method

Note: for complete sample see Downloader.Sample project from this repository.

Features at a glance

  • Download files async and non-blocking.
  • Cross-platform library to download any files with any size.
  • Get real-time progress info of each block.
  • Download file multipart as parallel.
  • Handle any client-side or server-side exception none-stopping the downloads.
  • Config your ChunkCount to define the parts count of the download file.
  • Download file multipart as in-memory or in-temp files cache mode.
  • Store download package object to resume the download when you want.
  • Get download speed or progress percentage in each progress event.
  • Get download progress events per chunk downloads
  • Stop and Resume your downloads with package object
  • Set a speed limit on downloads

Release Notes

Added ClearPackageAfterDownloadCompleted option

  • .NETStandard 2.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Downloader:

Package Downloads
ModuleLauncher.Re
ModuleLauncher.Re makes developing Minecraft launchers efficient and elegant

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on Downloader:

Repository Stars
goatcorp/FFXIVQuickLauncher
Custom launcher for Final Fantasy XIV

Version History

Version Downloads Last updated
1.9.7 124 11/12/2020
1.9.6 75 11/11/2020
1.9.5 91 11/11/2020
1.9.4 143 10/24/2020
1.9.3 84 10/19/2020
1.9.2 82 10/12/2020
1.9.1 120 9/28/2020
1.9.0 154 9/27/2020
1.8.0 297 7/31/2020
1.7.0 150 7/17/2020
1.6.0 121 7/14/2020
1.5.0 124 7/6/2020
1.4.0 195 7/4/2020
1.3.0 386 6/21/2020
1.2.1 214 6/21/2020
1.2.0 180 6/16/2020
1.1.0 173 5/29/2020
1.0.9 179 5/16/2020
1.0.8 111 5/11/2020
1.0.7 143 5/3/2020
1.0.6 131 4/22/2020
1.0.5 123 4/21/2020
1.0.4 146 4/16/2020
1.0.3 162 3/28/2020
1.0.2 154 3/28/2020
1.0.1 176 3/28/2020