Table of Contents

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

fileName string

The name of the file to download.

bytes byte[]

The file content as a byte array.

contentType string

The MIME content type of the file.

cancellationToken CancellationToken

A cancellation token to observe.

Returns

ValueTask

A ValueTask representing the asynchronous operation.

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

fileName string

The name of the file to download.

stream Stream

The stream containing the file content.

contentType string

The MIME content type of the file.

cancellationToken CancellationToken

A cancellation token to observe.

Returns

ValueTask

A ValueTask representing the asynchronous operation.

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

fileName string

The name of the file to download.

text string

The text content of the file.

encoding Encoding

The encoding to use when converting the text to bytes.

contentType string

The MIME content type of the file.

cancellationToken CancellationToken

A cancellation token to observe.

Returns

ValueTask

A ValueTask representing the asynchronous operation.