Table of Contents

Class BOBChunkedUploader

Namespace
BlazOrbit.Components.Forms
Assembly
BlazOrbit.dll

Streams an Microsoft.AspNetCore.Components.Forms.IBrowserFile to a consumer-supplied transport in fixed-size chunks. Opt-in helper used alongside BOBInputFile when a single InputFileChangeEventArgs.GetMultipleFiles round-trip is too large to buffer.

public sealed class BOBChunkedUploader
Inheritance
object
BOBChunkedUploader

Remarks

The helper is transport-agnostic — the consumer provides SendChunk and decides whether the destination is HTTP, SignalR, the file system, or something else. Chunks are emitted sequentially in index order; the helper awaits each SendChunk invocation before reading the next chunk, so a slow transport applies back-pressure on the read stream automatically.

Constructors

BOBChunkedUploader()

public BOBChunkedUploader()

Properties

ChunkSize

Chunk size in bytes. Defaults to 1 MB.

public int ChunkSize { get; init; }

Property Value

int

MaxAllowedSize

Hard ceiling for Microsoft.AspNetCore.Components.Forms.IBrowserFile.Size in bytes. Files larger than this fail before any chunk is read. Also forwarded as the maxAllowedSize argument to Microsoft.AspNetCore.Components.Forms.IBrowserFile.OpenReadStream(long, System.Threading.CancellationToken). Defaults to 100 MB.

public long MaxAllowedSize { get; init; }

Property Value

long

Progress

Optional progress sink invoked after each chunk is delivered.

public IProgress<BOBChunkedUploadProgress>? Progress { get; init; }

Property Value

IProgress<BOBChunkedUploadProgress>

SendChunk

Callback invoked for every chunk in index order. Awaited before the next chunk is read, so a slow consumer back-pressures the upload.

public required Func<BOBChunkContext, CancellationToken, Task> SendChunk { get; init; }

Property Value

Func<BOBChunkContext, CancellationToken, Task>

Methods

UploadAsync(IBrowserFile, CancellationToken)

Reads file chunk by chunk and forwards each to SendChunk. Zero-byte files emit no chunks and return a successful result with TotalChunks = 0. Errors thrown by the read stream, the callback, or cancellation are captured in Error — the method itself does not rethrow.

public Task<BOBChunkedUploadResult> UploadAsync(IBrowserFile file, CancellationToken ct = default)

Parameters

file IBrowserFile

The browser file to stream.

ct CancellationToken

Cancellation token honoured between chunks and inside reads.

Returns

Task<BOBChunkedUploadResult>