Soenneker.Utils.File.Download
4.0.1711
Prefix Reserved
See the version list below for details.
dotnet add package Soenneker.Utils.File.Download --version 4.0.1711
NuGet\Install-Package Soenneker.Utils.File.Download -Version 4.0.1711
<PackageReference Include="Soenneker.Utils.File.Download" Version="4.0.1711" />
<PackageVersion Include="Soenneker.Utils.File.Download" Version="4.0.1711" />
<PackageReference Include="Soenneker.Utils.File.Download" />
paket add Soenneker.Utils.File.Download --version 4.0.1711
#r "nuget: Soenneker.Utils.File.Download, 4.0.1711"
#:package Soenneker.Utils.File.Download@4.0.1711
#addin nuget:?package=Soenneker.Utils.File.Download&version=4.0.1711
#tool nuget:?package=Soenneker.Utils.File.Download&version=4.0.1711
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
- Polly (>= 8.7.0)
- Soenneker.Utils.Directory (>= 4.0.914)
- Soenneker.Utils.HttpClientCache (>= 4.0.2049)
- System.Threading.RateLimiting (>= 10.0.11)
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.1712 | 0 | 8/31/2026 |
| 4.0.1711 | 0 | 8/31/2026 |
| 4.0.1710 | 0 | 8/31/2026 |
| 4.0.1709 | 0 | 8/31/2026 |
| 4.0.1708 | 0 | 8/31/2026 |
| 4.0.1707 | 184 | 8/31/2026 |
| 4.0.1706 | 139 | 8/30/2026 |
| 4.0.1705 | 73 | 8/30/2026 |
| 4.0.1704 | 192 | 8/30/2026 |
| 4.0.1703 | 145 | 8/30/2026 |
| 4.0.1702 | 159 | 8/30/2026 |
| 4.0.1701 | 383 | 8/30/2026 |
| 4.0.1700 | 142 | 8/30/2026 |
| 4.0.1699 | 235 | 8/29/2026 |
| 4.0.1698 | 186 | 8/29/2026 |
| 4.0.1697 | 96 | 8/29/2026 |
| 4.0.1696 | 128 | 8/29/2026 |
| 4.0.1695 | 8,841 | 8/26/2026 |
| 4.0.1694 | 259 | 8/26/2026 |
| 4.0.1693 | 356 | 8/26/2026 |
Update dependency Soenneker.Utils.Directory to 4.0.914 (#2228)