Del via


HostedFileDownloadStream Class

Definition

Represents a stream for downloading file content from an AI service.

public ref class HostedFileDownloadStream abstract : System::IO::Stream
[System.Diagnostics.CodeAnalysis.Experimental("MEAI001", UrlFormat="https://aka.ms/dotnet-extensions-warnings/{0}")]
public abstract class HostedFileDownloadStream : System.IO.Stream
public abstract class HostedFileDownloadStream : System.IO.Stream
[<System.Diagnostics.CodeAnalysis.Experimental("MEAI001", UrlFormat="https://aka.ms/dotnet-extensions-warnings/{0}")>]
type HostedFileDownloadStream = class
    inherit Stream
type HostedFileDownloadStream = class
    inherit Stream
Public MustInherit Class HostedFileDownloadStream
Inherits Stream
Inheritance
HostedFileDownloadStream
Attributes

Remarks

This abstract class extends Stream to provide additional metadata about the downloaded file, such as its media type and file name. Implementations should override the abstract Stream members and optionally override MediaType and FileName to provide file metadata.

The ToDataContentAsync(CancellationToken) method provides a convenient way to buffer the entire stream content into a DataContent instance.

Constructors

Name Description
HostedFileDownloadStream()

Initializes a new instance of the HostedFileDownloadStream class.

Properties

Name Description
CanWrite

When overridden in a derived class, gets a value indicating whether the current stream supports writing.

FileName

Gets the file name.

MediaType

Gets the media type (MIME type) of the file content.

Methods

Name Description
BeginWrite(Byte[], Int32, Int32, AsyncCallback, Object)

Begins an asynchronous write operation. (Consider using WriteAsync(Byte[], Int32, Int32) instead.)

EndWrite(IAsyncResult)

Ends an asynchronous write operation. (Consider using WriteAsync(Byte[], Int32, Int32) instead.)

SetLength(Int64)

When overridden in a derived class, sets the length of the current stream.

ToDataContentAsync(CancellationToken)

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

Write(Byte[], Int32, Int32)

When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.

Write(ReadOnlySpan<Byte>)

When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.

WriteAsync(Byte[], Int32, Int32, CancellationToken)

Asynchronously writes a sequence of bytes to the current stream, advances the current position within this stream by the number of bytes written, and monitors cancellation requests.

WriteAsync(ReadOnlyMemory<Byte>, CancellationToken)

Asynchronously writes a sequence of bytes to the current stream, advances the current position within this stream by the number of bytes written, and monitors cancellation requests.

WriteByte(Byte)

Writes a byte to the current position in the stream and advances the position within the stream by one byte.

Extension Methods

Name Description
CopyToAsync(Stream, PipeWriter, CancellationToken)

Asynchronously reads the bytes from the Stream and writes them to the specified PipeWriter, using a cancellation token.

Applies to