Soenneker.Utils.File.Download
4.0.1812
Prefix Reserved
See the version list below for details.
dotnet add package Soenneker.Utils.File.Download --version 4.0.1812
NuGet\Install-Package Soenneker.Utils.File.Download -Version 4.0.1812
<PackageReference Include="Soenneker.Utils.File.Download" Version="4.0.1812" />
<PackageVersion Include="Soenneker.Utils.File.Download" Version="4.0.1812" />
<PackageReference Include="Soenneker.Utils.File.Download" />
paket add Soenneker.Utils.File.Download --version 4.0.1812
#r "nuget: Soenneker.Utils.File.Download, 4.0.1812"
#:package Soenneker.Utils.File.Download@4.0.1812
#addin nuget:?package=Soenneker.Utils.File.Download&version=4.0.1812
#tool nuget:?package=Soenneker.Utils.File.Download&version=4.0.1812
Soenneker.Utils.File.Download
Streams HTTP responses to files, with generated destination paths, bounded multi-file concurrency, and optional retries.
Installation
dotnet add package Soenneker.Utils.File.Download
Registration
builder.Services.AddFileDownloadUtilAsScoped();
Singleton registration is also available. The HTTP client cache remains singleton in either case; disposing a scoped downloader does not remove the shared cached client.
Download one file
string? savedPath = await downloader.Download(
"https://cdn.example.com/report.csv",
filePath: destinationPath,
cancellationToken: cancellationToken);
Instead of an explicit path, provide directory and fileExtension to generate a unique file there, or provide only fileExtension to generate a temporary path:
string? savedPath = await downloader.Download(
uri,
directory: downloadDirectory,
fileExtension: ".pdf",
cancellationToken: cancellationToken);
At least filePath or fileExtension is required. HTTP, stream, and filesystem failures return null and are logged when log is enabled. Requested cancellation throws OperationCanceledException.
Downloads are written to a temporary file beside the destination and moved into place only after the response body is complete. A failed or cancelled request therefore leaves an existing destination unchanged and removes its partial temporary file.
Retry
string? savedPath = await downloader.DownloadWithRetry(
uri,
filePath: destinationPath,
maxRetryAttempts: 3,
baseDelaySeconds: 2,
cancellationToken: cancellationToken);
maxRetryAttempts is the number of retries after the initial request. Non-positive values are normalized to one retry. With a base of 2, retry delays are 2, 4, and 8 seconds. A failed attempt returns null to the policy and is retried; cancellation is never retried.
Download multiple files
List<string> downloaded = await downloader.DownloadMultiple(
downloadDirectory,
uris,
maxConcurrentDownloads: 4,
cancellationToken: cancellationToken);
Each URI receives a unique destination derived from the URI. Per-file failures are logged and omitted from the result. Result order is completion-dependent and does not match input order. Cancellation stops the operation and throws.
HTTP ownership and security
Pass a configured HttpClient when you need custom handlers, authentication, proxy behavior, timeouts, or SSRF controls. The caller retains ownership of a supplied client. When no client is supplied, the utility reuses its named client from the singleton cache.
This utility does not restrict URI schemes or hosts, limit redirects, or enforce a maximum response size. Validate untrusted URIs, prevent access to internal/link-local destinations, and enforce size limits in the HTTP pipeline before exposing downloads to user input. A Content-Length header is used for progress reporting only and is not trusted as an enforcement boundary.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Kevlar (>= 1.3.0)
- Soenneker.Extensions.ValueTask (>= 4.0.127)
- Soenneker.Utils.File (>= 4.0.2303)
- Soenneker.Utils.HttpClientCache (>= 4.0.2115)
- Soenneker.Utils.Path (>= 4.0.1251)
- System.Threading.RateLimiting (>= 10.0.13)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on Soenneker.Utils.File.Download:
| Package | Downloads |
|---|---|
|
Soenneker.Coinbase.Runners.OpenApiClients.Cdp
This runner executes a GitHub action that updates another project. It's not meant for consumption. |
|
|
Soenneker.HighLevel.Runners.OpenApiClient
Automatically updates the Soenneker.HighLevel.OpenApiClient package |
|
|
Soenneker.HubSpot.Runners.OpenApiClient
This runner executes a GitHub action that updates another project. It's not meant for consumption. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 4.0.1820 | 1,796 | 10/15/2026 |
| 4.0.1819 | 50 | 10/15/2026 |
| 4.0.1818 | 788 | 10/14/2026 |
| 4.0.1817 | 888 | 10/14/2026 |
| 4.0.1813 | 868 | 10/14/2026 |
| 4.0.1812 | 387 | 10/14/2026 |
| 4.0.1804 | 1,106 | 10/13/2026 |
| 4.0.1802 | 266 | 10/13/2026 |
| 4.0.1799 | 3,749 | 10/12/2026 |
| 4.0.1798 | 288 | 10/12/2026 |
| 4.0.1797 | 238 | 10/11/2026 |
| 4.0.1795 | 1,289 | 10/11/2026 |
| 4.0.1793 | 189 | 10/11/2026 |
| 4.0.1792 | 12,173 | 9/30/2026 |
| 4.0.1790 | 155 | 9/30/2026 |
| 4.0.1789 | 1,635 | 9/29/2026 |
| 4.0.1788 | 400 | 9/29/2026 |
| 4.0.1787 | 1,467 | 9/29/2026 |
| 4.0.1786 | 419 | 9/29/2026 |
| 4.0.1785 | 998 | 9/29/2026 |
Use NuGet API token for publishing