Interface IDownloadFileService
- Namespace
- NuvTools.AspNetCore.Blazor.JSInterop
- Assembly
- NuvTools.AspNetCore.Blazor.dll
Provides functionality for downloading files in Blazor applications via JavaScript interop.
public interface IDownloadFileService : IAsyncDisposable
- Inherited Members
Methods
DownloadFileAsync(string, byte[], string, CancellationToken)
Downloads a file from a byte array.
ValueTask DownloadFileAsync(string fileName, byte[] bytes, string contentType = "application/octet-stream", CancellationToken cancellationToken = default)
Parameters
fileNamestringThe name of the file to download.
bytesbyte[]The file content as a byte array.
contentTypestringThe MIME content type of the file.
cancellationTokenCancellationTokenA cancellation token to observe.
Returns
DownloadFileAsync(string, Stream, string, CancellationToken)
Downloads a file from a stream. Large streams are sent in chunks to stay within SignalR message size limits.
ValueTask DownloadFileAsync(string fileName, Stream stream, string contentType = "application/octet-stream", CancellationToken cancellationToken = default)
Parameters
fileNamestringThe name of the file to download.
streamStreamThe stream containing the file content.
contentTypestringThe MIME content type of the file.
cancellationTokenCancellationTokenA cancellation token to observe.
Returns
DownloadFileFromTextAsync(string, string, Encoding, string, CancellationToken)
Downloads a file from a text string using the specified encoding.
ValueTask DownloadFileFromTextAsync(string fileName, string text, Encoding encoding, string contentType = "text/plain", CancellationToken cancellationToken = default)
Parameters
fileNamestringThe name of the file to download.
textstringThe text content of the file.
encodingEncodingThe encoding to use when converting the text to bytes.
contentTypestringThe MIME content type of the file.
cancellationTokenCancellationTokenA cancellation token to observe.