Skip to content

Inputs

FileUpload

Bit.BlazorUI

BitFileUpload sends the files a user picks, drops or pastes to a server endpoint over HTTP - whole or in resumable chunks - with per-file progress, pause, cancel, retry and server-side removal, validation on arrival, and a fully themable, templatable and screen-reader friendly UI. For file selection without uploading, use BitFileInput.

Usage

Every example is live. Open its code to see exactly what produced the component running underneath.

Basic

Browse, drop a file on the component, or paste one while it has the focus. Each file gets an item with an upload button that sends it to the UploadUrl, then a progress bar with pause and cancel, and finally a status message.

Label & description

LabelIconName (or LabelIcon for an external library) adds an icon to the browse button, placed by LabelIconPosition. Description - or DescriptionTemplate for markup - puts a hint under the button and wires it through aria-describedby, the place to state the limits up front.

PDF or DOCX, up to 5 MB.

Images only. Up to 2 MB.

Drop area & drop zones

ShowDropArea turns the browse button into a large dashed panel - still a single button, so it is reached with Tab and opened with Enter or Space.

Any file type, up to 10 MB each.


AllowDrop and AllowPaste switch the two extra routes off at runtime. A refused drop is still swallowed, so the browser never navigates away to the file.





DropZoneSelector makes any matching element a drop target too. While a drag is in flight every zone carries Classes.Dragging / Styles.Dragging, which is what highlights the card below.

Drop files anywhere in this card

Removable

ShowRemoveButton adds a remove button to each settled item. A file that never reached the server is just dropped; an uploaded one is deleted through a DELETE to the RemoveUrl (name in the query string, id in the BIT_FILE_ID header). The focus moves to the next item instead of being lost.

Selection behavior

Multiple takes several files at once, AutoUpload sends them as soon as they arrive, Append adds a new selection to the list instead of replacing it, and AutoReset empties the list before each browse. With AllowDuplicates off, re-picking a file already in the list is rejected.

Multiple, auto-uploaded:



Appending, without duplicates - try selecting the same file twice:



AutoReset - every browse starts from an empty list:

Validation

Rules run when a file arrives, however it arrives; a rejected file stays in the list with its reason and is never sent. MaxSize / MinSize bound each file, MaxTotalSize and MaxCount the whole list (re-checked after every removal), and FileValidator adds a rule of your own. Each has its own ...ErrorMessage.

Up to 1 MB per file.

Up to 3 files, 2 MB in total.

Empty (zero-byte) files are turned away.


AllowedExtensions is the type rule - extensions with or without the dot, or MIME types like image/* - and also fills the dialog filter. Accept alone only filters the dialog; a drop walks past it. When the rule is MIME-only, or a drag holds more files than MaxCount leaves room for, the drop indicator turns red before the drop (Classes.DraggingRejected restyles it).

Up to 3 images or PDFs - drag anything else over to see it refused.

GIF, JPG or MP4.

Accept only: the dialog filters, a dropped file of any type is still taken.

Directory & Capture

Directory picks - or accepts a drop of - a whole folder, subfolders included, with every file still validated. Capture opens the camera on a mobile device: "user" for the front one, "environment" for the rear one.

Up to 20 files out of the chosen folder.


Opens the rear camera on a mobile device.

Opens the front camera on a mobile device.

Preview & image dimensions

ShowPreview shows a thumbnail of each image, made in the browser and released on removal, and a type glyph for anything else. ReadImageDimensions fills Width / Height before validation, so a FileValidator can reject an image by its pixels.


Images between 200x200 and 4000x4000 pixels.

Events

OnChange, OnInvalid, OnUploading (set per-file headers here), OnProgress, OnUploadComplete / OnUploadFailed, OnRemoveComplete / OnRemoveFailed and OnAllUploadsComplete. Each file carries the server's ResponseStatus (0 when unreachable) and Message. Try a file over 1 MB.


No File

Chunked

ChunkedUpload sends each file as a series of requests, so a pause or a failure resumes from the last chunk. ChunkSize fixes the slice; AutoChunkSize adapts it to the connection (512 KB - 10 MB). Each chunk carries BIT_FILE_ID, Content-Range and BIT_CHUNK_FROM / BIT_CHUNK_TO / BIT_FILE_SIZE for the server to reassemble it.



Adaptive chunk sizing:

Http requests

Headers, query strings and extra form fields for the upload and remove requests are fixed at selection time.



Their async ...Provider counterparts run before every request - each file and each chunk - which is what keeps an expiring token or a presigned URL (UploadUrlProvider) fresh.


Requests so far: 0


The transport itself: UploadRequestHttpMethod, UploadFormFieldName, RemoveRequestHttpMethod, WithCredentials and a per-request UploadTimeout.

Retry

AutoRetries retries a failed upload, waiting AutoRetryDelay (or an AutoRetryDelayProvider backoff) in between. By default only failures a retry can fix are retried - network errors, timeouts, 408, 429, 5xx; ShouldAutoRetry replaces that rule. After the budget is spent the item offers a retry button (RetryIcon, RetryButtonTitle).

A 404 is not retried - the file fails at once:



A ShouldAutoRetry that insists, backing off 1s, 2s, 4s:

ConcurrentUploads

ConcurrentUploads caps how many files are on the wire at once; the rest wait in order, show the QueuedUploadMessage and can be canceled before their turn. 0 (the default) starts them all.



Batch actions

ShowBatchActions adds Upload all, Cancel all and Clear buttons under the list. They keep their places as uploads settle - an idle one is only marked unavailable - so keyboard focus is never lost. UploadAllText, CancelAllText and ClearText relabel them.



Progress & file list

OverallUploadProgress, TotalUploadSpeed and OverallRemainingTime summarize the batch, and each file has its own UploadSpeed and RemainingTime (null while not on the wire). Re-read them from OnProgress.


0 %


Batch: idle (-)


FileSizeFormatter replaces the built-in size text, and HideFileView leaves the list undrawn while the files are still uploaded and reported through Files.



No file selected yet.

Templates

LabelTemplate replaces the browse button - and its drop indicator, so bring your own through Classes.Dragging - and FileViewTemplate replaces each item, with the BitFileInfo as its context. Use real buttons with an aria-label naming the file, and the per-file Upload(file) / RemoveFile(file) overloads.


Public API

Browse, Upload, PauseUpload, CancelUpload, RemoveFile and Reset drive the component from code, each on one file or - with no argument - on all of them. Pause keeps the bytes sent so Upload resumes; cancel settles the file, which can be retried later. Files and UploadStatus report the state.


Preloaded files

PreloadedFiles lists the files a record already has on the server. They are never uploaded, show the PreloadedFileMessage, count towards MaxCount / MaxTotalSize, survive Reset, and their remove button deletes them through the RemoveUrl with their FileId. Read each one's Status back when saving.

Remove an existing attachment or add new ones.
invoice.pdf
80KB
Saved with this record
logo.png
14KB
Saved with this record
No file selected. 2 already attached.​

Accessibility

Every control is a real button with a visible focus ring, and each item action is labelled with its file name. The list is named by FileListAriaLabel, progress bars expose their value, and a live region announces selections and outcomes - reworded or translated through AnnouncementProvider. AriaLabel names the browse button when its text is not enough.


Variant

Variant sets how much of the Color the browse button carries: Fill (default), Outline or Text. Disabled, every variant takes the neutral disabled look.




Cascading parameters

BitParams hands a BitFileUploadParams to every file upload under it as defaults: a parameter an uploader sets itself wins, everything it leaves unset comes from the cascade.

Up to 5 MB per file.
Up to 5 MB per file.
Up to 5 MB per file.

Color

Color drives the browse button, the drop indicator, the progress bars, the hovered actions and the focus rings together.



Background, foreground and border colors:



A drop area in a role color:

External Icons

LabelIcon, UploadIcon, RetryIcon, PauseIcon, CancelIcon and RemoveIcon take a BitIconInfo or a raw class string from any loaded icon library (BitIconInfo.Fa(), .Bi(), .Css()).

FontAwesome:






Bootstrap:



Size

Size scales the browse button, the items, the action buttons, the icons and the thumbnails together; Medium is the default.



Style & Class

Style and Class land on the root; Styles and Classes reach every part, and their Dragging / DraggingRejected entries apply only during a drag.







The --bit-FileUpload-* variables (listed in the API section) inherit, so they work from an instance's Style, from any ancestor, or from :root.


RTL

Dir="BitDir.Rtl" mirrors the whole layout; the localizable texts complete it.

CSS variables

The public custom properties this component reads off its root, for what no parameter covers.

Every variable is read with a fallback and never declared by the component, so it inherits like any other custom property: set one on :root (or in a [bit-theme] block) to restyle every instance, on any ancestor to restyle the ones inside it, or on the Style of one instance to restyle that one alone. Leave a variable unset and the component falls back to the theme token beside it.

BitFileUpload CSS variables

Name Default value Description
--bit-FileUpload-max-width 21.875rem The widest the whole control grows.
--bit-FileUpload-gap 0.25rem Room between the browse button, the description and the file list, and between the file items themselves.
--bit-FileUpload-label-color Per Variant, from the Color role Browse button text at rest: the role's on-color in the Fill variant, the role's main color in Outline and Text.
--bit-FileUpload-label-background Per Variant, from the Color role Browse button fill at rest: the role's main color in the Fill variant, transparent in Outline and Text.
--bit-FileUpload-label-border-color Per Variant, from the Color role Browse button rule at rest. In the Fill variant it follows the background unless it is set on its own.
--bit-FileUpload-label-hover-color The Color role's on-color Browse button text while hovered or pressed (pointer devices only).
--bit-FileUpload-label-hover-background The Color role's hover color Browse button fill on hover, and its rule too in the Fill variant.
--bit-FileUpload-label-active-background The Color role's active color Browse button fill while pressed, and its rule too in the Fill variant.
--bit-FileUpload-label-radius --bit-shp-radius-button Corner radius of the browse button.
--bit-FileUpload-label-min-height The Size class's control height (--bit-siz-ctrl-sm/md/lg) Height floor of the browse button, which is what lines it up with the other controls of its size.
--bit-FileUpload-label-padding The Size class's control padding Padding of the browse button.
--bit-FileUpload-label-font-size Per Size, from the type ramp Text size of the browse button.
--bit-FileUpload-label-font-weight --bit-tpg-font-weight Text weight of the browse button.
--bit-FileUpload-label-gap 0.375rem Room between the browse button's icon and its text.
--bit-FileUpload-label-icon-size The Size class's icon size (--bit-siz-icon-sm/md/lg) Size of the browse button's icon (LabelIcon / LabelIconName).
--bit-FileUpload-drop-area-min-height 8rem Height floor of the ShowDropArea panel.
--bit-FileUpload-drop-area-padding 1.5rem Padding of the ShowDropArea panel.
--bit-FileUpload-drop-area-color --bit-clr-fg-pri Text color of the ShowDropArea panel.
--bit-FileUpload-drop-area-background --bit-clr-bg-sec Surface of the ShowDropArea panel at rest.
--bit-FileUpload-drop-area-border-color --bit-clr-brd-pri Dashed rule of the ShowDropArea panel at rest; the Color role takes over on hover and during a drag.
--bit-FileUpload-drop-area-border-style dashed Style of the ShowDropArea panel's rule.
--bit-FileUpload-drop-area-radius --bit-shp-radius-surface Corner radius of the ShowDropArea panel.
--bit-FileUpload-drop-area-hover-border-color The Color role's main color Rule of the ShowDropArea panel on hover and while pressed.
--bit-FileUpload-drop-area-hover-background The Color role's main color at 8% opacity Surface of the ShowDropArea panel on hover and while files are dragged over it.
--bit-FileUpload-drop-area-icon-color The Color role's main color Color of the ShowDropArea panel's large icon.
--bit-FileUpload-drop-area-icon-size 2rem Size of the ShowDropArea panel's large icon (--bit-FileUpload-label-icon-size wins when set).
--bit-FileUpload-focus-color The Color role's focus color Color of the keyboard focus ring, on the browse button and on every file action button.
--bit-FileUpload-description-color --bit-clr-fg-sec Color of the hint under the browse button.
--bit-FileUpload-description-font-size Per Size, from the type ramp Text size of the hint under the browse button.
--bit-FileUpload-item-color --bit-clr-fg-pri Text color of a file item.
--bit-FileUpload-item-background transparent Surface of a file item.
--bit-FileUpload-item-border-color --bit-clr-brd-pri Rule around a file item.
--bit-FileUpload-item-hover-border-color --bit-clr-brd-pri-hover Rule around a hovered file item (pointer devices only).
--bit-FileUpload-item-radius --bit-shp-radius-surface Corner radius of a file item.
--bit-FileUpload-item-padding 0.5rem 1rem Padding around the name, size and progress of a file item.
--bit-FileUpload-item-font-size Per Size, from the type ramp Text size of a file item's name.
--bit-FileUpload-item-font-weight --bit-tpg-fw-light Text weight of a file item's name.
--bit-FileUpload-item-meta-font-size Per Size, from the type ramp Text size of the size and percentage line under a file item's name.
--bit-FileUpload-list-max-height none Tallest the file list grows before it scrolls, for a folder or a long batch.
--bit-FileUpload-success-color --bit-clr-suc Status line of a completed file.
--bit-FileUpload-error-color --bit-clr-err Status line of a failed or rejected file.
--bit-FileUpload-paused-color The Color role's main color Status line of a paused or canceled file.
--bit-FileUpload-preloaded-color --bit-clr-fg-sec Status line of a file that was already on the server when the list was built.
--bit-FileUpload-preview-size Per Size (2rem / 2.5rem / 3.25rem) Side of the image preview thumbnail.
--bit-FileUpload-preview-radius --bit-shp-radius-control Corner radius of the image preview thumbnail.
--bit-FileUpload-preview-background --bit-clr-bg-sec Fill of the box that stands in for the thumbnail of a file that is not an image.
--bit-FileUpload-preview-icon-color --bit-clr-fg-sec The file type glyph inside that box.
--bit-FileUpload-preview-icon-size Per Size (--bit-siz-icon-sm / -md / -lg) Size of that glyph.
--bit-FileUpload-progress-color The Color role's main color Filled part of a file's progress bar.
--bit-FileUpload-progress-track-color --bit-clr-bg-sec Unfilled part of a file's progress bar.
--bit-FileUpload-progress-height --bit-siz-track-sm Thickness of a file's progress bar.
--bit-FileUpload-progress-radius --bit-shp-radius-full Corner radius of a file's progress bar and its track.
--bit-FileUpload-action-color --bit-clr-fg-pri Glyph of the upload, pause, cancel and remove buttons at rest.
--bit-FileUpload-action-hover-color The Color role's main color The same glyph while hovered (pointer devices only).
--bit-FileUpload-action-hover-background The Color role's main color at 10% opacity Tint behind a hovered action button.
--bit-FileUpload-action-size The Size class's control height (--bit-siz-ctrl-sm/md/lg) Width of an action button, which is also the width of the removal spinner's slot.
--bit-FileUpload-action-icon-size The Size class's icon size (--bit-siz-icon-sm/md/lg) Size of an action button's glyph, and of the removal spinner.
--bit-FileUpload-spinner-color The Color role's main color Arc of the spinner shown while a file is being removed from the server.
--bit-FileUpload-drop-color The Color role's on-color Browse button text while files are dragged over the component.
--bit-FileUpload-drop-background The Color role's hover color Browse button fill in the same state.
--bit-FileUpload-drop-border-color The Color role's on-color Browse button rule in the same state.
--bit-FileUpload-drop-border-style dashed Style of that rule, which is what makes the drop indicator read as a drop target.
--bit-FileUpload-drop-reject-color --bit-clr-err-text Browse button text while the dragged files are known to be turned away (a MIME type the rule refuses, or more files than MaxCount leaves room for).
--bit-FileUpload-drop-reject-background --bit-clr-err Browse button fill in the same state.
--bit-FileUpload-drop-reject-border-color --bit-clr-err-text Browse button rule in the same state.
--bit-FileUpload-batch-action-color The Color role's main color Text of the Upload all, Cancel all and Clear buttons.
--bit-FileUpload-batch-action-hover-background The Color role's main color at 10% opacity Tint behind a hovered batch action button.
--bit-FileUpload-disabled-color --bit-clr-fg-dis Text color when IsEnabled is false.
--bit-FileUpload-disabled-background --bit-clr-bg-dis Fill of a disabled browse button in the Fill variant and of a disabled drop area.
--bit-FileUpload-disabled-border-color --bit-clr-brd-dis Rule of a disabled browse button in the Fill and Outline variants.

API

Every parameter, public member, sub-class and enum this component exposes.

BitFileUpload parameters

Name Type Default value Description
Accept string? null Accepted file types for the file browser using MIME types or file extensions (e.g., "image/*", ".pdf,.doc"), applied to the accept attribute of the underlying input element. When not set, the accept attribute is generated from AllowedExtensions.
AllowDrop bool true Whether files can be selected by dragging them from the operating system and dropping them on the component.
AllowDuplicates bool true Whether a file that is already in the file list can be selected again. When disabled, a newly selected file matching an existing one by name, size and last modified time is rejected with the DuplicateErrorMessage instead of being uploaded a second time, becoming eligible again once the file it duplicates is removed. A file of PreloadedFiles counts as one already in the list, matched by name and size alone since a server reports no modification time.
AllowedExtensions IReadOnlyCollection<string> ["*"] Allowed file types for validation purposes, accepting both file extensions (with an optional leading dot, case-insensitive) and MIME types with an optional wildcard (e.g., "image/*"). Use ["*"] to allow all file types. Files not matching any of these entries will not be uploaded.
AllowPaste bool true Whether files can be selected by pasting them from the clipboard onto the component. The paste is only captured while the focus is inside the component.
AnnouncementProvider Func<IReadOnlyList<BitFileInfo>, string?>? null Custom provider of the text announced by the screen reader through the live region of the component whenever the file list or an upload outcome changes. Receives the current file list and returns the text to announce, or null to announce nothing. When not set, a built-in English announcement is used.
Append bool false Whether a new selection is added to the end of the current file list instead of replacing it, which is what lets the user build a batch up over several rounds of browsing, dropping or pasting. The files already in the list keep their upload state.
AutoChunkSize bool false Calculate the chunk size dynamically based on the user's Internet speed between 512 KB and 10 MB.
AutoReset bool false Whether the file list and the upload state are cleared right before the file dialog opens, so that every browse starts from a clean slate - the list empties even if the dialog is then cancelled.
AutoRetries int 0 The number of times a failed upload of a file gets retried automatically before it is reported as failed. In the chunked mode each retry resumes from the last successfully uploaded chunk. Set to 0 (the default) to disable the automatic retries.
AutoRetryDelay TimeSpan? null The delay before each automatic retry of a failed upload. Set to null (the default) to retry immediately.
AutoRetryDelayProvider Func<BitFileInfo, int, TimeSpan?>? null Custom delay before each automatic retry, which is what turns the fixed AutoRetryDelay into a backoff: it receives the file - whose ResponseStatus says what the server answered - and the number of the attempt about to be made, counting from 1, and returns how long to wait before it. Returning null falls back to the AutoRetryDelay, which is also what a provider that throws does, so a miscalculated delay never swallows the retry itself.
AutoUpload bool false Whether the selected files start uploading the moment they are selected, skipping the per-file upload button entirely, for the cases where the selection itself expresses the intent to upload.
CancelButtonTitle string? null The tooltip of the cancel upload button, which is also used as the prefix of its accessible label (e.g., "Cancel report.pdf"). Defaults to "Cancel".
CancelAllText string Cancel all The text of the "Cancel all" button of the batch actions (see ShowBatchActions).
CancelIcon BitIconInfo? null The icon to use for the cancel upload button using custom CSS classes for external icon libraries. Takes precedence over CancelIconName when both are set.
CancelIconName string? null The name of the icon to use for the cancel upload button from the built-in Fluent UI icons. Defaults to Cancel when not set.
CanceledUploadMessage string File upload canceled The message shown for canceled file uploads.
Capture string? null The capture behavior of the file input on devices with a camera or microphone, rendered as the capture attribute of the input element (e.g., "user" for the front camera, "environment" for the rear camera).
ChunkedUpload bool false Whether each file is sliced and sent as a series of sequential requests instead of one monolithic one, which is what makes a paused or failed file resume from the last chunk that made it through rather than starting over, so a dropped connection costs one chunk instead of the whole transfer.
ChunkSize long? null The size in bytes of each chunk of a chunked upload. When not set - and whenever AutoChunkSize is enabled, which takes the decision over - it starts at 512 KB.
Classes BitFileUploadClassStyles? null Custom CSS classes for different parts of the BitFileUpload.
ClearText string Clear The text of the "Clear" button of the batch actions (see ShowBatchActions), which resets the component.
Color BitColor? null The general color of the file upload, applied to the browse button, the drag-and-drop indicator, the progress bars and the hovered action buttons.
ConcurrentUploads int 0 The maximum number of files uploading at the same time, the remaining ones waiting in a queue in selection order and starting as soon as a slot frees up. Set to 0 (the default) to start every file at once.
Description string? null A short hint rendered under the browse button and wired to it through aria-describedby, which is the place to spell out the accepted file types and the size limits so that both sighted and screen reader users learn the constraints before hitting them.
DescriptionTemplate RenderFragment? null Custom Razor template of the hint rendered under the browse button, taking precedence over Description.
Directory bool false Whether to select folders (directories) instead of files, rendered as the webkitdirectory attribute. All files inside the selected folder and its subfolders will be added to the file list. It also makes a dropped folder expand into its contents instead of being ignored.
DropZoneSelector string? null A CSS selector of one or more elements outside the component that accept a drop as well, which is how a whole form, a card or the page itself becomes the drop target while the browse button stays where it is. The root element is always a drop zone and needs no selector of its own; the elements this one names are matched whenever a drag reaches them, so one rendered later is a drop zone from the moment it matches. While files are dragged over any of them, all of them carry the Classes.Dragging class and the Styles.Dragging inline style, and the focus being inside one of them is also what lets a paste land in this component.
DuplicateErrorMessage string The file is already selected The message shown for the files rejected for being already in the file list while AllowDuplicates is disabled.
FailedRemoveMessage string File remove failed The message shown for failed file removes.
FailedUploadMessage string File upload failed The message shown for failed file uploads.
FileListAriaLabel string Selected files The accessible name of the file list, so that a screen reader user landing on it is told what the list they are in holds instead of only how many items it has. Set it to an empty string to leave the list unnamed.
FileSizeFormatter Func<long, string>? null Custom formatter of the file size shown under the name of each file item. Receives the size of the file in bytes and returns the text to display, which is the place to localize the units or to switch between the binary and the decimal bases. When not set, a built-in humanizer is used.
FileValidator Func<BitFileInfo, string?>? null Custom validation function called for each newly selected file after the built-in validations pass. Return an error message to reject the file so it will not be uploaded, or null to accept it.
FileViewTemplate RenderFragment<BitFileInfo>? null Custom Razor template rendering each item of the file list in place of the built-in one, receiving the file as its context with its name, size, progress, speed and status all available. It is only asked for the files that are actually in the list, so a removed file leaves no empty item behind.
HideFileView bool false Whether the built-in file list is left unrendered. The files are still selected, validated, uploaded and reported through the Files property and the callbacks - they are simply not drawn, which is what the surrounding page needs when it shows the attachments in a layout of its own.
HideLabel bool false Whether to hide the default browse button label from the UI.
Label string Browse The text of the browse button. Setting it to an empty string hides the button altogether.
LabelIcon BitIconInfo? null The icon of the browse button using custom CSS classes for external icon libraries. Takes precedence over LabelIconName when both are set.
LabelIconName string? null The name of the icon of the browse button from the built-in Fluent UI icons. Defaults to CloudUpload in the ShowDropArea mode, and to no icon otherwise.
LabelIconPosition BitIconPosition? null The position of the icon of the browse button relative to its text: Start (the default) or End. In the ShowDropArea mode the icon is stacked above or below the text instead.
LabelTemplate RenderFragment? null Custom Razor template rendered in place of the browse button, which also replaces the built-in dashed drop indicator living on that button - a custom label should bring its own drag feedback through the Dragging entry of Classes or Styles.
MaxCount int 0 Maximum allowed number of files in the file list (0 for unlimited). Files selected beyond this count are rejected at selection time and will not be uploaded. Only files that pass the other validations consume a slot.
MaxCountErrorMessage string The maximum number of files is exceeded Specifies the message shown for the files rejected due to exceeding the maximum number of files.
MaxSize long 0 The maximum allowed size in bytes of each file (0 for unlimited). A larger file is rejected at selection time with the MaxSizeErrorMessage and will not be uploaded.
MaxSizeErrorMessage string The file size is larger than the max size The message shown for the files rejected for being larger than the MaxSize.
MaxTotalSize long 0 Maximum allowed total size in bytes of all the files of the file list (0 for unlimited). Files pushing the accumulated size beyond this limit are rejected at selection time and will not be uploaded, becoming eligible again once removals free up room. Only files that pass the other validations consume the budget.
MaxTotalSizeErrorMessage string The total size of the files is larger than the max total size Specifies the message shown for the files rejected for making the total size of the file list exceed the maximum total size.
MinSize long 0 The minimum allowed size in bytes of each file (0 for no limit). A smaller file is rejected at selection time with the MinSizeErrorMessage and will not be uploaded.
MinSizeErrorMessage string The file size is smaller than the min size The message shown for the files rejected for being smaller than the MinSize.
Multiple bool false Whether several files can be handed over at once, both through the file dialog and through a single drop or paste. Without it a multi-file drop or paste is trimmed down to its first file.
NotAllowedExtensionErrorMessage string The file type is not allowed The message shown for the files rejected for not matching any entry of AllowedExtensions.
OnAllUploadsComplete EventCallback<BitFileInfo[]> Callback for when every file of a batch that actually started uploading has reached a terminal state - completed, failed, canceled, removed or rejected by the validations. A selection that was never asked to upload never settles, so it never reports itself as complete.
OnChange EventCallback<BitFileInfo[]> Callback for when file or files status change. It is invoked with the whole file list right after a selection, and with only the file that changed whenever a single status changes afterwards, so the current state of the batch is better read back from the Files property than from the argument.
OnInvalid EventCallback<BitFileInfo[]> Callback invoked right after OnChange whenever a selection carries at least one file rejected by the validations, providing an array of only the rejected files along with their messages.
OnProgress EventCallback<BitFileInfo> Callback for when the upload of a file makes progress, invoked on every progress report of the browser with the file whose TotalUploadedSize, UploadSpeed and RemainingTime have just moved.
OnRemoveComplete EventCallback<BitFileInfo> Callback for when a file has been removed, whether it was dropped from the list on this side or deleted from the server through the RemoveUrl.
OnRemoveFailed EventCallback<BitFileInfo> Callback for when the removal of a file from the server failed, leaving the file in the list with the FailedRemoveMessage rather than pretending it is gone.
OnUploading EventCallback<BitFileInfo> Callback for when a file upload is about to start, invoked before the request that carries its first byte and therefore once per run of the file rather than once per chunk. It is the place to attach the HttpHeaders and the FormFields that belong to this one file, both of which are read again for every request it makes.
OnUploadComplete EventCallback<BitFileInfo> Callback for when a file has been uploaded successfully, with the body of the server response of its last request on its Message.
OnUploadFailed EventCallback<BitFileInfo> Callback for when the upload of a file failed for good - after the automatic retries, if any, have all been spent - with the body of the failed response on its Message.
PauseButtonTitle string? null The tooltip of the pause upload button, which is also used as the prefix of its accessible label (e.g., "Pause report.pdf"). Defaults to "Pause".
PauseIcon BitIconInfo? null The icon to use for the pause upload button using custom CSS classes for external icon libraries. Takes precedence over PauseIconName when both are set.
PauseIconName string? null The name of the icon to use for the pause upload button from the built-in Fluent UI icons. Defaults to Pause when not set.
PreloadedFileMessage string Already uploaded The status message shown for the files of PreloadedFiles, which are already on the server rather than freshly uploaded and would otherwise read as an upload that just succeeded.
PreloadedFiles IReadOnlyCollection<BitFileInfo>? null The files that are already on the server, shown in the list from the start so that a form editing a record can present the attachments it already has next to the ones the user is adding. They carry no content on this side, so they are never uploaded: each starts out completed, counts towards MaxCount and MaxTotalSize like any other file, and its remove button deletes it from the server through the RemoveUrl with its FileId in the BIT_FILE_ID header. The list is built from the collection again whenever the files in it change - which files, by their FileId, rather than which array they arrive in - and the instances in it are the very ones the list then holds, so their Status is where to read what became of each of them.
QueuedUploadMessage string Waiting to upload The message shown for the files waiting in the queue for a free slot of the ConcurrentUploads limit, which is what tells a file that is about to start apart from one that was never asked to upload.
ReadImageDimensions bool false Whether to read the pixel dimensions of the selected image files, filling the Width and Height of each of them before the validations run, so that a FileValidator can reject an image by its dimensions. Reading them means decoding every image in the browser, which costs time and memory on a large selection, so it is off by default.
RemoveButtonTitle string? null The tooltip of the remove file button, which is also used as the prefix of its accessible label (e.g., "Remove report.pdf"). Defaults to "Remove".
RemoveIcon BitIconInfo? null The icon to use for the remove file button using custom CSS classes for external icon libraries. Takes precedence over RemoveIconName when both are set.
RemoveIconName string? null The name of the icon to use for the remove file button from the built-in Fluent UI icons. Defaults to Delete when not set.
RemoveRequestHttpHeaders Dictionary<string, string>? null Custom HTTP headers attached to the remove request.
RemoveRequestHttpHeadersProvider Func<Task<Dictionary<string, string>>>? null The provider function creating the HTTP headers of the remove request, invoked right before the request goes out and taking precedence over RemoveRequestHttpHeaders.
RemoveRequestHttpMethod string? null The HTTP method of the remove request (e.g., "POST"). Defaults to "DELETE".
RemoveRequestQueryStrings Dictionary<string, string>? null Custom query strings appended to the URL of the remove request.
RemoveRequestQueryStringsProvider Func<Task<Dictionary<string, string>>>? null The provider function creating the query strings of the remove request, invoked right before the request goes out and taking precedence over RemoveRequestQueryStrings.
RemoveUrl string? null URL of the server endpoint removing the files. A file whose bytes already reached the server is deleted from it through a request to this URL carrying its name as a query string and its id in the BIT_FILE_ID header; a file that never uploaded is simply dropped from the list without one.
RetryButtonTitle string? null The tooltip of the retry button of a failed or canceled file, which is also used as the prefix of its accessible label (e.g., "Retry report.pdf"). Falls back to UploadButtonTitle and then to "Retry".
RetryIcon BitIconInfo? null The icon to use for the retry button of a failed or canceled file using custom CSS classes for external icon libraries. Takes precedence over RetryIconName when both are set.
RetryIconName string? null The name of the icon to use for the retry button of a failed or canceled file from the built-in Fluent UI icons. Falls back to UploadIconName and then to Refresh.
ShouldAutoRetry Func<BitFileInfo, int, bool>? null Decides whether a failed upload is worth retrying automatically, receiving the file and the HTTP status code of the failed request (0 for a network error, a timeout or an aborted request) and returning true to spend one of the AutoRetries attempts on it. When not set, a built-in rule retries network errors, timeouts, 408, 429 and the 5xx server errors, and gives up right away on the other 4xx.
ShowBatchActions bool false Whether an action bar with "Upload all", "Cancel all" and "Clear" buttons is rendered under the file list. A button with nothing to act on stays in place, marked aria-disabled, so the focus is never lost to it. The AutoUpload mode leaves out "Upload all".
ShowDropArea bool false Whether the browse button is rendered as a large drop area - a full-width dashed panel with an icon over the Label - instead of a regular button. It stays a real button, so it is reached with Tab and opens the file dialog with Enter or Space.
ShowPreview bool false Whether a thumbnail of every selected image is shown at the head of its file item, produced entirely in the browser from an object URL that is handed back as soon as the file is removed or the component is reset. The same URL is on the PreviewUrl of each file. A file that is not an image takes a glyph of its type in a box of the same size instead, so that the names of a mixed list stay lined up along one edge.
ShowRemoveButton bool false Whether each settled file item offers a remove button, which drops a file that never uploaded from the list and deletes an uploaded one from the server through the RemoveUrl.
Size BitSize? null The size of the file upload, applied to the browse button and the file list items.
Styles BitFileUploadClassStyles? null Custom CSS styles for different parts of the BitFileUpload.
SuccessfulUploadMessage string File upload succeeded The message shown for successful file uploads.
UploadAllText string Upload all The text of the "Upload all" button of the batch actions (see ShowBatchActions).
UploadButtonTitle string? null The tooltip of the upload button, which is also used as the prefix of its accessible label (e.g., "Upload report.pdf"). Defaults to "Upload".
UploadFormFieldName string? null The name of the form field carrying the file content in the upload request. Defaults to "file".
UploadIcon BitIconInfo? null The icon to use for the upload button using custom CSS classes for external icon libraries. Takes precedence over UploadIconName when both are set.
UploadIconName string? null The name of the icon to use for the upload button from the built-in Fluent UI icons. Defaults to Play when not set.
UploadRequestFormFields Dictionary<string, string>? null Additional multipart form fields sent alongside the content of every file in its upload requests, for the endpoints that read their metadata from the form rather than from the query string. The FormFields of a file is merged over these for that file.
UploadRequestHttpHeaders Dictionary<string, string>? null Custom HTTP headers attached to the upload requests, fixed at selection time.
UploadRequestHttpHeadersProvider Func<Task<Dictionary<string, string>>>? null The provider function to create the http headers for upload request. Unlike UploadRequestHttpHeaders, it is invoked right before every single request - each file and each chunk - which is what lets it hand over a freshly minted access token.
UploadRequestHttpMethod string? null The HTTP method of the upload request (e.g., "PUT"). Defaults to "POST".
UploadRequestQueryStrings Dictionary<string, string>? null Custom query strings appended to the URL of the upload requests, fixed at selection time.
UploadRequestQueryStringsProvider Func<Task<Dictionary<string, string>>>? null The provider function to create the query strings for upload request. Unlike UploadRequestQueryStrings, it is invoked right before every single request - each file and each chunk - which is what lets it hand over a value that does not survive a batch.
UploadTimeout TimeSpan? null The timeout of the upload request for each file or chunk. When it elapses the upload of the file fails. Set to null (the default) for no timeout.
UploadUrl string? null URL of the server endpoint receiving the files, fixed at selection time. Use UploadUrlProvider instead for an endpoint that has to be minted per request.
UploadUrlProvider Func<Task<string?>>? null The provider function to create the URL of the server endpoint receiving the files. Unlike UploadUrl, it is invoked right before every single request - each file and each chunk - which is what lets it hand over a presigned URL that expires.
Variant BitVariant? null The visual variant of the browse button, which decides how much of the Color it carries: a full fill, only an outline, or neither.
WithCredentials bool false Whether the upload request is sent with credentials such as cookies and authorization headers for cross-origin requests (the withCredentials flag of the underlying XMLHttpRequest).

BitFileUpload public members

Name Type Default value Description
Files IReadOnlyList<BitFileInfo> [] A list of all of the selected files to upload.
UploadStatus BitFileUploadStatus Pending The current status of the file uploader.
InputId string? null The id of the file input element.
IsRemoving bool false Indicates that the file upload is in the middle of removing a file.
TotalSize long 0 The total size in bytes of all the files of the batch, excluding the removed ones and the ones rejected by the validations.
TotalUploadedSize long 0 The total uploaded size in bytes across all the files of the batch, excluding the removed ones and the ones rejected by the validations.
OverallUploadProgress int 0 The overall upload progress of the batch as a percentage (0 to 100), combining the progress of all the files weighted by their size.
TotalUploadSpeed double? null The combined speed in bytes per second of every file of the batch that is uploading right now, which is what the connection as a whole is carrying. It is null while nothing is on the wire.
OverallRemainingTime TimeSpan? null The estimated time left before the whole batch is uploaded, derived from the TotalUploadSpeed and the bytes of the batch that are still to be sent. It is null whenever nothing is uploading and the speed is therefore unknown.
Upload (BitFileInfo? fileInfo = null, string? uploadUrl = null) => Task Starts uploading a specific file, or all files when no file is specified, resuming a paused or chunked file from the last chunk that made it through and retrying a failed or canceled one with a fresh budget of automatic retries. A file whose request is already on the wire is left running rather than being started over.
PauseUpload (BitFileInfo? fileInfo = null) => Task Pauses the upload of a specific file, or all files when no file is specified, applying to the files that are on their way: an in-progress file aborts its in-flight request and keeps the bytes that made it, and a file waiting in the concurrency queue is taken out of it. Both can be resumed later through the Upload method. A file that was never asked to upload, and one that has already settled, are left as they are.
CancelUpload (BitFileInfo? fileInfo = null) => Task Cancels the upload of a specific file, or all files when no file is specified, settling every file that is still in play - running, queued, paused or merely selected - as canceled right away and aborting the in-flight request of a running one. A file that has already settled is left alone, and a canceled file can be started again later.
RemoveFile (BitFileInfo? fileInfo = null) => Task Removes a specific file, or all files when no file is specified, deleting the (partially) uploaded ones from the server through the RemoveUrl.
Browse () => Task Opens a file selection dialog.
Reset () => Task Resets the file upload, clearing the file list and the upload state. The files of PreloadedFiles stay, since they belong to the record rather than to this selection - except the ones already deleted from the server, which nothing on this side brings back.

BitComponentBase parameters

Name Type Default value Description
AriaLabel string? null Gets or sets the accessible label for the component, used by assistive technologies.
Class string? null Gets or sets the CSS class name(s) to apply to the rendered element.
Dir BitDir? null Gets or sets the text directionality for the component's content.
ForceAnimation bool false Gets or sets a value indicating whether the component's animations play at their full duration even when reduced motion is requested.
HtmlAttributes Dictionary<string, object> new Dictionary<string, object>() Captures additional HTML attributes to be applied to the rendered element, in addition to the component's parameters.
Id string? null Gets or sets the unique identifier for the component's root element.
IsEnabled bool true Gets or sets a value indicating whether the component is enabled and can respond to user interaction.
Style string? null Gets or sets the CSS style string to apply to the rendered element.
TabIndex string? null Gets or sets the tab order index for the component when navigating with the keyboard.
Visibility BitVisibility BitVisibility.Visible Gets or sets the visibility state (visible, hidden, or collapsed) of the component.

BitComponentBase public members

Name Type Default value Description
UniqueId Guid Guid.NewGuid() Gets the readonly unique identifier for the component's root element, assigned when the component instance is constructed.
RootElement ElementReference Gets the reference to the root HTML element associated with this component.

BitIconInfo properties

Name Type Default value Description
Name string? null Gets or sets the name of the icon.
BaseClass string? null Gets or sets the base CSS class for the icon. For built-in Fluent UI icons, this defaults to "bit-icon". For external icon libraries like FontAwesome, you might set this to "fa" or leave empty.
Prefix string? null Gets or sets the CSS class prefix used before the icon name. For built-in Fluent UI icons, this defaults to "bit-icon--". For external icon libraries, you might set this to "fa-" or leave empty.

BitFileInfo properties

Name Type Default value Description
ContentType string string.Empty The Content-Type of the selected file.
Name string string.Empty The name of the selected file.
Size long The size of the selected file.
FileId string string.Empty The file ID of the selected file, this is a GUID.
Index int The index of the file among the ones picked in this browser, which is what names the transfer behind it. A preloaded file was never picked and has no transfer of its own, so its index is -1.
LastModified long The last modified time of the file reported by the browser, in milliseconds since the Unix epoch.
LastModifiedDate DateTimeOffset The last modified time of the file reported by the browser, as a DateTimeOffset.
LastChunkUploadedSize long The size of the last uploaded chunk of the file.
TotalUploadedSize long The total uploaded size of the file.
PreviewUrl string? null An object URL of the file content that can be used as the source of an img element to preview image files. This is only populated for image files when the ShowPreview parameter of the BitFileUpload is enabled.
Width int? null The width of the image in pixels, only populated for decodable image files when the ReadImageDimensions parameter of the BitFileUpload is enabled. It is null for anything else.
Height int? null The height of the image in pixels, only populated for decodable image files when the ReadImageDimensions parameter of the BitFileUpload is enabled. It is null for anything else.
UploadSpeed double? null The observed speed of the upload of this file in bytes per second, measured over the request currently in flight. It is null while the file is not uploading and until the first progress report arrives.
RemainingTime TimeSpan? null The estimated time left before the upload of this file completes, derived from the UploadSpeed and the bytes still to be sent. It is null whenever the speed is unknown.
IsQueued bool false Whether the file is waiting in the upload queue for a free slot of the ConcurrentUploads limit, which is what tells a file that is about to start apart from one that was never asked to upload.
IsPreloaded bool false Whether the file was handed over through the PreloadedFiles parameter instead of being picked in the browser, which is to say it is already on the server: there is no content on this side to send, so it is never uploaded, and removing it deletes it from the server through the RemoveUrl.
Message string? null The message attached to the current Status of the file: the reason it was rejected by the validations before the upload, or the body of the server response of its upload or removal.
ResponseStatus int? null The HTTP status code of the last upload or removal response this file received, which is what tells an authorization problem from a payload that was too large or from a server that is temporarily down. It is 0 when the request never reached the server at all - a network error, a timeout or an abort - and null while no request of this file has come back yet.
Status BitFileUploadStatus Pending The status of the file in the BitFileUpload.
HttpHeaders Dictionary<string, string>? null Additional custom HTTP headers attached to the upload requests of this specific file (e.g., set from the OnUploading callback).
FormFields Dictionary<string, string>? null Additional multipart form fields sent alongside the content of this specific file in its upload requests, merged over the ones of the UploadRequestFormFields parameter of the BitFileUpload. The natural place to fill it in is the OnUploading callback.

BitFileUploadClassStyles properties

Name Type Default value Description
Root string? null Custom CSS classes/styles for the root element of the BitFileUpload.
Dragging string? null Custom CSS classes/styles for the root element while files are being dragged over the BitFileUpload.
DraggingRejected string? null Custom CSS classes/styles added on top of Dragging while the dragged files are known to be turned away - a MIME type the AllowedExtensions rule does not accept, or more files than the MaxCount leaves room for.
Label string? null Custom CSS classes/styles for the browse button (label) of the BitFileUpload.
LabelIcon string? null Custom CSS classes/styles for the icon of the browse button of the BitFileUpload.
Description string? null Custom CSS classes/styles for the description (hint) of the BitFileUpload.
FileList string? null Custom CSS classes/styles for the file list container of the BitFileUpload.
FileItem string? null Custom CSS classes/styles for each file item of the BitFileUpload.
Preview string? null Custom CSS classes/styles for the image preview thumbnail of each file item of the BitFileUpload, and for the box that takes its place with a type glyph for a file that is not an image.
PreviewIcon string? null Custom CSS classes/styles for the type glyph shown in place of the preview thumbnail of a file item that is not an image.
FileName string? null Custom CSS classes/styles for the file name of each file item of the BitFileUpload.
FileSize string? null Custom CSS classes/styles for the file size of each file item of the BitFileUpload.
Percentage string? null Custom CSS classes/styles for the upload percent indicator of each file item of the BitFileUpload.
ProgressBarContainer string? null Custom CSS classes/styles for the progress bar container of each file item of the BitFileUpload.
ProgressBar string? null Custom CSS classes/styles for the progress bar of each file item of the BitFileUpload.
StatusMessage string? null Custom CSS classes/styles for the status message of each file item of the BitFileUpload.
UploadButton string? null Custom CSS classes/styles for the upload button of each file item of the BitFileUpload.
UploadIcon string? null Custom CSS classes/styles for the upload button icon of each file item of the BitFileUpload.
PauseButton string? null Custom CSS classes/styles for the pause button of each file item of the BitFileUpload.
PauseIcon string? null Custom CSS classes/styles for the pause button icon of each file item of the BitFileUpload.
CancelButton string? null Custom CSS classes/styles for the cancel button of each file item of the BitFileUpload.
CancelIcon string? null Custom CSS classes/styles for the cancel button icon of each file item of the BitFileUpload.
RemoveButton string? null Custom CSS classes/styles for the remove button of each file item of the BitFileUpload.
RemoveIcon string? null Custom CSS classes/styles for the remove button icon of each file item of the BitFileUpload.
RemoveSpinnerContainer string? null Custom CSS classes/styles for the container of the spinner that takes the place of the remove button of a file item while that file is being removed from the server.
RemoveSpinner string? null Custom CSS classes/styles for the spinner that takes the place of the remove button of a file item while that file is being removed from the server.
BatchActions string? null Custom CSS classes/styles for the container of the batch action buttons of the BitFileUpload.
BatchActionButton string? null Custom CSS classes/styles for each batch action button (Upload all, Cancel all, Clear) of the BitFileUpload.

BitColor enum

Name Value Description
Primary 0 Primary general color.
Secondary 1 Secondary general color.
Tertiary 2 Tertiary general color.
Info 3 Info general color.
Success 4 Success general color.
Warning 5 Warning general color.
SevereWarning 6 SevereWarning general color.
Error 7 Error general color.
PrimaryBackground 8 Primary background color.
SecondaryBackground 9 Secondary background color.
TertiaryBackground 10 Tertiary background color.
PrimaryForeground 11 Primary foreground color.
SecondaryForeground 12 Secondary foreground color.
TertiaryForeground 13 Tertiary foreground color.
PrimaryBorder 14 Primary border color.
SecondaryBorder 15 Secondary border color.
TertiaryBorder 16 Tertiary border color.

BitSize enum

Name Value Description
Small 0 The small size file upload.
Medium 1 The medium size file upload.
Large 2 The large size file upload.

BitIconPosition enum

Name Value Description
Start 0 The icon is placed before the text.
End 1 The icon is placed after the text.

BitVariant enum

Name Value Description
Fill 0 Fill styled variant.
Outline 1 Outline styled variant.
Text 2 Text styled variant.

BitFileUploadStatus enum

Name Value Description
Pending 0 The file is selected and queued, and its uploading has not started yet.
InProgress 1 File uploading is in progress.
Paused 2 File uploading progress is paused by the user.
Canceled 3 File uploading progress is canceled by the user.
Completed 4 The file is successfully uploaded.
Failed 5 The file has a problem and progress is failed.
Removed 6 The uploaded file removed by the user.
RemoveFailed 7 The file removal failed.
NotAllowed 8 The file is rejected by the validations (size, count, type or a custom rule) and will not be uploaded.

BitVisibility enum

Name Value Description
Visible 0 The content of the component is visible.
Hidden 1 The content of the component is hidden, but the space it takes on the page remains (visibility:hidden).
Collapsed 2 The component is hidden (display:none).

BitDir enum

Name Value Description
Ltr 0 Ltr (left to right) is to be used for languages that are written from the left to the right (like English).
Rtl 1 Rtl (right to left) is to be used for languages that are written from the right to the left (like Arabic).
Auto 2 Auto lets the user agent decide. It uses a basic algorithm as it parses the characters inside the element until it finds a character with a strong directionality, then applies that directionality to the whole element.

Feedback

Found a mistake, a gap, or something that could be clearer? Every page and every component is one click from its source.