Share via


HostedFileClientExtensions.DownloadToAsync Method

Definition

Downloads a file and saves it to a local path.

public static System.Threading.Tasks.Task<string> DownloadToAsync(this Microsoft.Extensions.AI.IHostedFileClient client, string fileId, string destinationPath, Microsoft.Extensions.AI.HostedFileClientOptions? options = default, System.Threading.CancellationToken cancellationToken = default);
static member DownloadToAsync : Microsoft.Extensions.AI.IHostedFileClient * string * string * Microsoft.Extensions.AI.HostedFileClientOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<string>
<Extension()>
Public Function DownloadToAsync (client As IHostedFileClient, fileId As String, destinationPath As String, Optional options As HostedFileClientOptions = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of String)

Parameters

client
IHostedFileClient

The file client.

fileId
String

The ID of the file to download.

destinationPath
String

The path to save the file to. If the path is a directory or empty, the file name will be inferred. An empty path is treated as the current directory.

options
HostedFileClientOptions

Options to configure the download.

cancellationToken
CancellationToken

The CancellationToken to monitor for cancellation requests.

Returns

The actual path where the file was saved.

Exceptions

destinationPath is null.

fileId is empty or whitespace.

A file at the destination path already exists.

Applies to