Share via


HostedFileDownloadStream.ToDataContentAsync(CancellationToken) Method

Definition

Reads the entire stream content from its current position and returns it as a DataContent.

public virtual System.Threading.Tasks.Task<Microsoft.Extensions.AI.DataContent> ToDataContentAsync(System.Threading.CancellationToken cancellationToken = default);
abstract member ToDataContentAsync : System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.Extensions.AI.DataContent>
override this.ToDataContentAsync : System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.Extensions.AI.DataContent>
Public Overridable Function ToDataContentAsync (Optional cancellationToken As CancellationToken = Nothing) As Task(Of DataContent)

Parameters

cancellationToken
CancellationToken

The CancellationToken to monitor for cancellation requests.

Returns

A DataContent containing the buffered file content.

Remarks

This method buffers the entire stream content into memory. For large files, consider streaming directly to the destination instead.

Applies to