Soenneker.Utils.File.Download
4.0.1714
Prefix Reserved
See the version list below for details.
dotnet add package Soenneker.Utils.File.Download --version 4.0.1714
NuGet\Install-Package Soenneker.Utils.File.Download -Version 4.0.1714
<PackageReference Include="Soenneker.Utils.File.Download" Version="4.0.1714" />
<PackageVersion Include="Soenneker.Utils.File.Download" Version="4.0.1714" />
<PackageReference Include="Soenneker.Utils.File.Download" />
paket add Soenneker.Utils.File.Download --version 4.0.1714
#r "nuget: Soenneker.Utils.File.Download, 4.0.1714"
#:package Soenneker.Utils.File.Download@4.0.1714
#addin nuget:?package=Soenneker.Utils.File.Download&version=4.0.1714
#tool nuget:?package=Soenneker.Utils.File.Download&version=4.0.1714
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.File (>= 4.0.2246)
- Soenneker.Utils.HttpClientCache (>= 4.0.2050)
- Soenneker.Utils.Path (>= 4.0.1209)
- 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.1715 | 0 | 9/1/2026 |
| 4.0.1714 | 0 | 9/1/2026 |
| 4.0.1713 | 0 | 9/1/2026 |
| 4.0.1712 | 5 | 8/31/2026 |
| 4.0.1711 | 87 | 8/31/2026 |
| 4.0.1710 | 85 | 8/31/2026 |
| 4.0.1709 | 588 | 8/31/2026 |
| 4.0.1708 | 354 | 8/31/2026 |
| 4.0.1707 | 260 | 8/31/2026 |
| 4.0.1706 | 181 | 8/30/2026 |
| 4.0.1705 | 103 | 8/30/2026 |
| 4.0.1704 | 238 | 8/30/2026 |
| 4.0.1703 | 176 | 8/30/2026 |
| 4.0.1702 | 188 | 8/30/2026 |
| 4.0.1701 | 471 | 8/30/2026 |
| 4.0.1700 | 171 | 8/30/2026 |
| 4.0.1699 | 278 | 8/29/2026 |
| 4.0.1698 | 214 | 8/29/2026 |
| 4.0.1697 | 124 | 8/29/2026 |
| 4.0.1696 | 157 | 8/29/2026 |
Update dependency Soenneker.Utils.File to 4.0.2246 (#2231)