Important Notice - Forums is archived

To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Product icon

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.

Downloading Files

Matthew Snook
1 decade ago May 04, 2012 10:44pm
Syam Pillai
1 decade ago May 05, 2012 12:50pm

JFileChooser? That is a swing component, you can not use it with vaadin because your vaadin front-end is a browser and not a desktop.

Henri Sara
1 decade ago May 07, 2012 5:57am
Matthew Snook
1 decade ago May 07, 2012 4:46pm
Henri Sara
1 decade ago May 08, 2012 6:07am

Matthew Snook: Technically, I am not even downloading a file as much as I am creating one, as the file does not exist until the button is pressed.

You should consider this a download from point of view of the browser and therefore the application even though the content may be dynamically created and maybe even never exists on the server. There should be examples downloading a file generated on the fly (StreamResource, ...). on the forum.

If the APIs you use only generate files on the disk (- not output streams etc.), you could give a temporary location on the server file system and then provide the file to download from there.

Matthew Snook
1 decade ago May 18, 2012 6:30pm
Boris Mitioglov
9 years ago Apr 01, 2013 5:26pm
Henri Sara
9 years ago Apr 02, 2013 1:13pm
Boris Mitioglov
9 years ago Apr 03, 2013 1:29pm

Henri Sara: Maybe this tutorial helps with Vaadin 7.

Thank you for your advice. It really helps me.

esource res = new FileResource(new File(basepath +
FileDownloader fd = new FileDownloader(res);

It's so easy to download from server in Vaadin