Table of Contents

Method CreateFromStreamAsync

Namespace
LMKit.Data
Assembly
LM-Kit.NET.dll

CreateFromStreamAsync(Stream, string, CancellationToken)

Creates a new Attachment instance asynchronously by reading content from the provided stream.

public static Task<Attachment> CreateFromStreamAsync(Stream data, string name, CancellationToken cancellationToken = default)

Parameters

data Stream

A readable Stream containing the attachment data. The stream is fully read; it is not disposed by this method.

name string

The logical file name associated with this attachment.

cancellationToken CancellationToken

A token to monitor for cancellation requests.

Returns

Task<Attachment>

A task that represents the asynchronous operation. The task result contains the loaded Attachment.

Exceptions

ArgumentNullException

Thrown when data or name is null.

ArgumentException

Thrown when data is not readable.

UnsupportedFileTypeException

Thrown if the stream data is not one of the supported formats.

OperationCanceledException

Thrown when the operation is canceled.

See Also