Table of Contents

Method CreateFromStreamAsync

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

CreateFromStreamAsync(Stream, string, CancellationToken)

Creates a new Attachment instance that references the provided stream directly, without copying its content into managed memory.

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

Parameters

data Stream

A readable, seekable Stream containing the attachment data. The stream is referenced directly — no copy is made. The caller retains ownership: the stream is not disposed by this instance, and it must remain open and valid for the lifetime of the Attachment.

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 created Attachment.

Exceptions

ArgumentNullException

Thrown when data or name is null.

ArgumentException

Thrown when data is not readable or not seekable.

UnsupportedFileTypeException

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

OperationCanceledException

Thrown when the operation is canceled.

See Also
Share