Class StreamExtension
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
clientHttpClientThe HttpClient instance to be used to retrieve the Stream.
urlstringThe URL of the file to download.
fromPoslongThe start position of the file.
toPoslong?The end position of the file.
tokenCancellationTokenA cancellation token for the asynchronous operation.
Returns
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
clientHttpClientThe HttpClient instance to be used to retrieve the Stream.
urlUriThe URL of the file to download.
fromPoslongThe start position of the file.
toPoslong?The end position of the file.
tokenCancellationTokenA cancellation token for the asynchronous operation.