Method Signatures and Parameters | |
Jt.fileUploader(String label) | label (String) A short label explaining to the user what this file uploader is for. Markdown is supported, see |
Chainable builder methods | |
type(List<String> types) | The allowed file extensions or MIME types. If |
acceptMultipleFiles(io.jeamlit.components.media.FileUploaderComponent.MultipleFiles acceptMultipleFiles) | Whether to accept more than one file in a submission. This can be one of the following values:
|
help(String help) | A tooltip that gets displayed next to the text. If this is |
disabled(boolean disabled) | Disable the file uploader if set to true. When disabled, users cannot interact with the widget. |
onChange(function.Consumer<List<JtUploadedFile>> onChange) | An optional callback invoked when the file uploader's value changes. |
labelVisibility(JtComponent.LabelVisibility labelVisibility) | The visibility of the label. The default is |
width(String width) | The width of the element. This can be one of the following:
|
width(int widthPixels) | The width of the text element in pixels. The element will have a fixed width. If the specified width is greater than the width of the parent container, the width of the element matches the width of the parent container. |
key(String key) | A string to use as the unique key for the widget. If this is omitted, a key will be generated for the widget based on its content. No two widgets may have the same key. |
No description | |
use() | Put the widget in the app, in the |
use(JtContainer container) | Put the widget in the app, in the provided container. |
Returns after .use() | |
(JtUploadedFile>) | The current JtUploadedFile> value of the component. |
Examples
Basic file upload with processing
import io.jeamlit.core.Jt;
import io.jeamlit.core.JtUploadedFile;
import java.util.List;
public class FileUploadApp {
public static void main(String[] args) {
var uploadedFiles = Jt.fileUploader("Choose a CSV file")
.type(List.of(".csv"))
.use();
if (!uploadedFiles.isEmpty()) {
JtUploadedFile file = uploadedFiles.getFirst();
Jt.text("Uploaded file: " + file.filename()).use();
Jt.text("File size: " + file.content().length + " bytes").use();
Jt.text("Content type: " + file.contentType()).use();
}
}
}
Still have questions?
Go to our discussions forum for helpful information and advice from Jeamlit experts.