Directory

← Back

File Download Wrapper

Helper add-on for making easy clickable file downloads.

Author

Contributors

Rating

This add-on is meant as a semi-replacement for the FileDownloader extension in earlier Vaadin versions. You can use it to create clickable download links or wrap components like buttons to achieve the same.

Sample code

    TextField textField = new TextField("Enter file contents");
    FileDownloadWrapper link = new FileDownloadWrapper("textfield.txt", () -> textField.getValue().getBytes());
    link.setText("Download textfield.txt that has contents of the TextField");
        Button button = new Button("Click to download");
        FileDownloadWrapper buttonWrapper = new FileDownloadWrapper(
            new StreamResource("foo.txt", () -> new ByteArrayInputStream("foo".getBytes())));
        buttonWrapper.wrapComponent(button);
        add(buttonWrapper);

Compatibility

(Loading compatibility data...)

Was this helpful? Need more help?
Leave a comment or a question below. You can also join the chat on Discord or ask questions on StackOverflow.

Version

Added DownloadBytesProvider interface for even easier usage.

Released
2018-10-04
Maturity
EXPERIMENTAL
License
Apache License 2.0

Compatibility

Framework
Vaadin 10+
Vaadin 14+ in 3.0.0
Vaadin 23+ in 5.0.0
Vaadin 24+ in 7.0.0
Browser
N/A
Online