Skip to main content

IFileDownloader interface

Namespace: Velopack.Sources

A simple abstractable file downloader

public interface IFileDownloader

Methods

MethodSummary
DownloadFileDownloads a remote file to the specified local path
DownloadBytesReturns a byte array containing the contents of the file at the specified url
DownloadStringReturns a string containing the contents of the specified url

DownloadFile(url, targetFile, progress, headers, timeout, cancelToken)

Task DownloadFile(string url, string targetFile, Action<int> progress, IDictionary<string, string>? headers = null, double timeout = 30, CancellationToken cancelToken = default)

Downloads a remote file to the specified local path

Parameters

NameTypeDescription
urlstringThe url which will be downloaded.
targetFilestringThe local path where the file will be stored
If a file exists at this path, it will be overwritten.
progressAction<int>A delegate for reporting download progress, with expected values from 0-100.
headersIDictionary<string, string>Headers that can be passed to Http Downloader, e.g. Accept or Authorization.
timeoutdoubleThe maximum time in minutes to wait for the download to complete.
cancelTokenCancellationTokenOptional token to cancel the request.

Returns Task

DownloadBytes(url, headers, timeout)

Task<byte[]> DownloadBytes(string url, IDictionary<string, string>? headers = null, double timeout = 30)

Returns a byte array containing the contents of the file at the specified url

Parameters

NameTypeDescription
urlstring
headersIDictionary<string, string>
timeoutdouble

Returns Task<byte[]>

DownloadString(url, headers, timeout)

Task<string> DownloadString(string url, IDictionary<string, string>? headers = null, double timeout = 30)

Returns a string containing the contents of the specified url

Parameters

NameTypeDescription
urlstring
headersIDictionary<string, string>
timeoutdouble

Returns Task<string>


Generated from Velopack 1.1.1