Table of Contents

Interface IDownloadService

Namespace
CivitaiSharp.Tools.Downloads
Assembly
CivitaiSharp.Tools.dll

Service for downloading images and model files from Civitai.

public interface IDownloadService

Methods

DownloadAsync(Image, string, CancellationToken)

Downloads an image to a specific base directory, using the configured path pattern.

Task<Result<DownloadedFile>> DownloadAsync(Image image, string baseDirectory, CancellationToken cancellationToken = default)

Parameters

image Image

The image to download.

baseDirectory string

The base directory to save the image to.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<Result<DownloadedFile>>

A result containing the downloaded file information on success.

DownloadAsync(Image, CancellationToken)

Downloads an image using the configured image download options.

Task<Result<DownloadedFile>> DownloadAsync(Image image, CancellationToken cancellationToken = default)

Parameters

image Image

The image to download.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<Result<DownloadedFile>>

A result containing the downloaded file information on success.

DownloadAsync(ModelFile, ModelVersion, string, CancellationToken)

Downloads a model file with version context to a specific base directory.

Task<Result<DownloadedFile>> DownloadAsync(ModelFile file, ModelVersion version, string baseDirectory, CancellationToken cancellationToken = default)

Parameters

file ModelFile

The model file to download.

version ModelVersion

The model version providing additional context.

baseDirectory string

The base directory to save the file to.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<Result<DownloadedFile>>

A result containing the downloaded file information on success.

DownloadAsync(ModelFile, ModelVersion, CancellationToken)

Downloads a model file with version context using the configured model download options.

Task<Result<DownloadedFile>> DownloadAsync(ModelFile file, ModelVersion version, CancellationToken cancellationToken = default)

Parameters

file ModelFile

The model file to download.

version ModelVersion

The model version providing additional context.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<Result<DownloadedFile>>

A result containing the downloaded file information on success.

Remarks

Providing the version context enables additional path pattern tokens such as {VersionName}, {BaseModel}, {ModelName}, {ModelType}, and {Creator}.

DownloadAsync(ModelFile, string, CancellationToken)

Downloads a model file to a specific base directory, using the configured path pattern.

Task<Result<DownloadedFile>> DownloadAsync(ModelFile file, string baseDirectory, CancellationToken cancellationToken = default)

Parameters

file ModelFile

The model file to download.

baseDirectory string

The base directory to save the file to.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<Result<DownloadedFile>>

A result containing the downloaded file information on success.

DownloadAsync(ModelFile, CancellationToken)

Downloads a model file using the configured model download options.

Task<Result<DownloadedFile>> DownloadAsync(ModelFile file, CancellationToken cancellationToken = default)

Parameters

file ModelFile

The model file to download.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<Result<DownloadedFile>>

A result containing the downloaded file information on success.

DownloadAsync(string, string, string, HashAlgorithm, CancellationToken)

Downloads a file from a raw URL with hash verification.

Task<Result<DownloadedFile>> DownloadAsync(string url, string destinationPath, string expectedHash, HashAlgorithm algorithm, CancellationToken cancellationToken = default)

Parameters

url string

The URL to download from.

destinationPath string

The full path where the file will be saved.

expectedHash string

The expected hash value for verification.

algorithm HashAlgorithm

The hash algorithm to use for verification.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<Result<DownloadedFile>>

A result containing the downloaded file information on success.

DownloadAsync(string, string, CancellationToken)

Downloads a file from a raw URL to a specific destination path.

Task<Result<DownloadedFile>> DownloadAsync(string url, string destinationPath, CancellationToken cancellationToken = default)

Parameters

url string

The URL to download from.

destinationPath string

The full path where the file will be saved.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<Result<DownloadedFile>>

A result containing the downloaded file information on success.