Skip to main content

File Upload

Rocket 2.0

The File Upload component lets users drag and drop or browse for files, such as attachments, images or CSV imports. It checks each file's type and size and can turn CSV, TSV and JSON files into data.

Properties​

Property
Description
Expected Value
LabelLabel shown above the drop zone.Text. Default: Attachments
Help textHelp text shown under the label.Text
TitleMain text inside the drop zone.Text. Default: Drag & drop files here
Hint (empty: accepted types and size)Smaller text under the title. Leave it empty to list the accepted file types, the size limit and the file limit.Text
Accept file typesComma-separated file types the user can pick, as MIME types or extensions, for example image/*,application/pdf,.csv. Other files are rejected with a message.Text. Default: image/*,application/pdf
Allow multiple filesLets the user add more than one file. When off, a new file replaces the current one.On or off. Default: On
Max filesMost files the user can add when Allow multiple files is on. Extra files are not added.Number. Default: 5
Max size (bytes, 0 for no limit)Largest file size accepted, in bytes. Use 0 for no limit.Number. Default: 5242880
Min size (bytes)Smallest file size accepted, in bytes.Number. Default: 0
Show image thumbnailsShows a thumbnail for image files in the file list instead of a file-type icon.On or off. Default: On
Parse content (CSV, TSV, JSON)Reads CSV, TSV and JSON files into data, available in each file's parsedData.On or off. Default: Off
Parse asHow files are parsed when Parse content is on. Autodetect from type uses the file's extension and type.Autodetect from type, CSV, TSV, JSON. Default: Autodetect from type
CSV delimiterCharacter that separates values in CSV files when parsing.Text. Default: ,

Additional Actions​

Each of these can be switched on or off, or set with a logical expression by clicking fx.

Property
Description
Expected Value
VisibilityShows or hides the component. Hidden components keep their space unless Collapse when hidden is on.On or off. Default: On
Collapse when hiddenRemoves the hidden component's space, so the components below it move up.On or off. Default: Off
Loading stateShows the component's loading look and blocks interaction, for example while a query runs.On or off. Default: Off
DisableStops the user from interacting with the component.On or off. Default: Off
Dynamic heightLets the component grow with its content in the running app instead of keeping a fixed height.On or off. Default: Off

Devices​

Property
Description
Expected Value
Show on desktopShows the component in the desktop layout.On or off. Default: On
Show on mobileShows the component in the mobile layout.On or off. Default: Off

Events​

Add a handler from the Events section of the properties panel. See Event Triggers for the steps.

Event
Description
On file selectedTriggers when one or more files are added to the list.
On file deselectedTriggers when the user removes a file or the files are cleared.
On file loadedTriggers when added files have finished reading and parsing.

Component Specific Actions (CSA)​

Run these from an event handler with Control Component, or from a RunJS query. See Component Specific Actions.

Action
Description
How To Access
Clear filesRemoves all files from the list.components.fileupload1.clearFiles()
Set file nameRenames a file and keeps its extension. Pass the file's position as Index or updates and the name as New name, or pass a list of { index, newFileName } objects to rename several.components.fileupload1.setFileName("", "")
Set visibilityShows the component when true, hides it when false.components.fileupload1.setVisibility(false)
Set disableDisables the component when true, enables it when false.components.fileupload1.setDisable(false)
Set loadingTurns the loading state on with true, off with false.components.fileupload1.setLoading(false)

Exposed Variables​

Variable
Description
How To Access
labelLabel shown above the drop zone.{{components.fileupload1.label}}
descriptionHelp text shown under the label.{{components.fileupload1.description}}
titleMain text inside the drop zone.{{components.fileupload1.title}}
hintSmaller text under the title. Leave it empty to list the accepted file types, the size limit and the file limit.{{components.fileupload1.hint}}
acceptComma-separated file types the user can pick, as MIME types or extensions, for example image/*,application/pdf,.csv. Other files are rejected with a message.{{components.fileupload1.accept}}
multipleLets the user add more than one file. When off, a new file replaces the current one.{{components.fileupload1.multiple}}
maxFilesMost files the user can add when Allow multiple files is on. Extra files are not added.{{components.fileupload1.maxFiles}}
maxSizeLargest file size accepted, in bytes. Use 0 for no limit.{{components.fileupload1.maxSize}}
minSizeSmallest file size accepted, in bytes.{{components.fileupload1.minSize}}
showPreviewShows a thumbnail for image files in the file list instead of a file-type icon.{{components.fileupload1.showPreview}}
parseContentReads CSV, TSV and JSON files into data, available in each file's parsedData.{{components.fileupload1.parseContent}}
parseFileTypeHow files are parsed when Parse content is on. Autodetect from type uses the file's extension and type.{{components.fileupload1.parseFileType}}
delimiterCharacter that separates values in CSV files when parsing.{{components.fileupload1.delimiter}}
fileList of the selected files. Each has name, type, size, content, base64Data, dataURL, and parsedData and parseError when Parse content is on.{{components.fileupload1.file}}
fileSizeTotal size of the selected files, in bytes.{{components.fileupload1.fileSize}}
isParsingtrue while added files are still being read and parsed.{{components.fileupload1.isParsing}}
isVisibleWhether the component is visible.{{components.fileupload1.isVisible}}
isLoadingWhether the component is in its loading state.{{components.fileupload1.isLoading}}
isDisabledWhether the component is disabled.{{components.fileupload1.isDisabled}}

Styles​

Style
Default
Label colorTheme: Primary text
Help text colorTheme: Placeholder text
Dropzone backgroundtransparent
Dropzone border colorTheme: Default border
Upload icon colorTheme: Placeholder text
Upload icon backgroundTheme: Surface 3
Title colorTheme: Primary text
Hint colorTheme: Placeholder text
Accent (drag over, browse link)Theme: Brand primary
File row backgroundTheme: Surface 1
File row border colorTheme: Default border
Error colorTheme: Error
Radius—
Box shadow0px 0px 0px 0px #00000040

A default that starts with Theme: follows the app's theme until the style is set to another value. See App Themes.