HostedFileClientExtensions.DownloadAsDataContentAsync Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Downloads a file and returns its content as a buffered DataContent.
public static System.Threading.Tasks.Task<Microsoft.Extensions.AI.DataContent> DownloadAsDataContentAsync(this Microsoft.Extensions.AI.IHostedFileClient client, string fileId, Microsoft.Extensions.AI.HostedFileClientOptions? options = default, System.Threading.CancellationToken cancellationToken = default);
static member DownloadAsDataContentAsync : Microsoft.Extensions.AI.IHostedFileClient * string * Microsoft.Extensions.AI.HostedFileClientOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.Extensions.AI.DataContent>
<Extension()>
Public Function DownloadAsDataContentAsync (client As IHostedFileClient, fileId As String, Optional options As HostedFileClientOptions = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of DataContent)
Parameters
- client
- IHostedFileClient
The file client.
- fileId
- String
The ID of the file to download.
- options
- HostedFileClientOptions
Options to configure the download.
- cancellationToken
- CancellationToken
The CancellationToken to monitor for cancellation requests.
Returns
The file content as a DataContent.
Exceptions
fileId is null.
fileId is empty or whitespace.
Remarks
This method buffers the entire file content into memory. For large files, consider using DownloadAsync(String, HostedFileClientOptions, CancellationToken) and streaming directly to the destination.