Table of Contents

Method CreateFromUriAsync

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

CreateFromUriAsync(Uri, AttachmentDownloadingProgressCallback, CancellationToken)

Creates a new Attachment instance asynchronously by loading content from the specified URI.

public static Task<Attachment> CreateFromUriAsync(Uri uri, Attachment.AttachmentDownloadingProgressCallback downloadingProgress = null, CancellationToken cancellationToken = default)

Parameters

uri Uri

The URI to load the attachment from. Supports file:// for local files and http:// or https:// for remote resources.

downloadingProgress Attachment.AttachmentDownloadingProgressCallback

An optional callback to report download progress for remote URIs. The callback receives the total content length (if known) and bytes read so far. Return false to cancel the download.

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 uri is null.

FileNotFoundException

Thrown when a local file URI points to a non-existent file.

UnsupportedFileTypeException

Thrown when the downloaded content is not a supported format.

HttpRequestException

Thrown when the remote resource cannot be downloaded.

OperationCanceledException

Thrown when the operation is canceled.

See Also