Class PluginFiles
Contains extensions related with Download operations and Copy-to routine.
public static class PluginFiles
- Inheritance
-
PluginFiles
- Inherited Members
Methods
CopyToAsyncProgress(Stream, Stream, FileReadProgressDelegate?, int, CancellationToken)
Performing copy operation from and to Stream asynchronously.
public static Task CopyToAsyncProgress(this Stream source, Stream destination, PluginFiles.FileReadProgressDelegate? progress, int bufferSize = 65536, CancellationToken token = default)
Parameters
sourceStreamThe source Stream to copy from.
destinationStreamThe target Stream to copy into.
progressPluginFiles.FileReadProgressDelegateA callback which reports the progress of the copy operation.
bufferSizeintThe buffer size required to perform the copy operation.
tokenCancellationTokenA cancellation token for the async operation
Returns
DownloadFilesAsync(HttpClient, string, Stream, FileReadProgressDelegate?, int, int, CancellationToken)
Perform an asynchronous download operation to a target Stream.
public static Task DownloadFilesAsync(this HttpClient client, string fileUrl, Stream outputStream, PluginFiles.FileReadProgressDelegate? downloadProgress, int bufferSize = 65536, int retryAttempt = 5, CancellationToken token = default)
Parameters
clientHttpClientAn HTTP client to be used for downloading the file.
fileUrlstringThe URL of the file.
outputStreamStreamThe target Stream in which the data will be downloaded to.
downloadProgressPluginFiles.FileReadProgressDelegateA callback which sends the progress of the download operation.
bufferSizeintHow many bytes being used as a buffer for the download operation.
retryAttemptintHow many retry attempts are used in case of failure.
tokenCancellationTokenA cancellation token for the async operation
Returns
Remarks
The first argument of PluginFiles.FileReadProgressDelegate delegate (read) passed by downloadProgress callback will send a negative number if a retry attempt is triggered.
This to avoid overflowed number if you're counting how many bytes are progressed using its read argument.