Soenneker.Utils.File.Download 4.0.1711

Prefix Reserved
There is a newer version of this package available.
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
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Soenneker.Utils.File.Download" Version="4.0.1711" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.Utils.File.Download" Version="4.0.1711" />
                    
Directory.Packages.props
<PackageReference Include="Soenneker.Utils.File.Download" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Soenneker.Utils.File.Download --version 4.0.1711
                    
#r "nuget: Soenneker.Utils.File.Download, 4.0.1711"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Soenneker.Utils.File.Download@4.0.1711
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Soenneker.Utils.File.Download&version=4.0.1711
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Utils.File.Download&version=4.0.1711
                    
Install as a Cake Tool

alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
Loading failed

Update dependency Soenneker.Utils.Directory to 4.0.914 (#2228)