Table of Contents

Class StreamExtension

Namespace
Hi3Helper.Plugin.Core.Utility
Assembly
Hi3Helper.Plugin.Core.dll

Provides extension methods for working with Stream objects and HttpClient.

public static class StreamExtension
Inheritance
StreamExtension
Inherited Members

Remarks

This class includes methods for creating streams from HTTP resources, allowing partial file downloads by specifying start and end positions. It also provides utility methods for safely accessing stream properties.

Methods

CreateHttpBridgedStream(HttpClient, string, long, long?, CancellationToken)

Creates a Stream from HttpClient from specified start and end position of the file.

public static Task<Stream> CreateHttpBridgedStream(this HttpClient client, string url, long fromPos = 0, long? toPos = null, CancellationToken token = default)

Parameters

client HttpClient

The HttpClient instance to be used to retrieve the Stream.

url string

The URL of the file to download.

fromPos long

The start position of the file.

toPos long?

The end position of the file.

token CancellationToken

A cancellation token for the asynchronous operation.

Returns

Task<Stream>

CreateHttpBridgedStream(HttpClient, Uri, long, long?, CancellationToken)

Creates a Stream from HttpClient from specified start and end position of the file.

public static Task<Stream> CreateHttpBridgedStream(this HttpClient client, Uri url, long fromPos = 0, long? toPos = null, CancellationToken token = default)

Parameters

client HttpClient

The HttpClient instance to be used to retrieve the Stream.

url Uri

The URL of the file to download.

fromPos long

The start position of the file.

toPos long?

The end position of the file.

token CancellationToken

A cancellation token for the asynchronous operation.

Returns

Task<Stream>