Download multiple files at once

I implemented a download at a button click with:
StreamResource resource = new StreamResource(“foo.docx”,
() → new ByteArrayInputStream(“foo”.getBytes()));
final StreamRegistration registration = VaadinSession.getCurrent().getResourceRegistry().registerResource(resource);
UI.getCurrent().getPage().open(registration.getResourceUri());

But i need to be able to download 2 files at once (word and excel), I tried to just insert this statement with a different file after that but it just let me download one file. Can anybody help?

There are some solutions in JavaScript but it’s usually blocked by the browser ( for security reasons). It’s probably better to create a zip on the server side to download the 2 files at once ( or create two links)

The HTTP protocol does not support multiple downloads at once. You can either fake it somehow with Javascript or zip them.

we experimented a lot with javascript triggered downloads and every modern browser did block everything we tried - so we are also switched to the “create zip file” solution. Also see my answer here: https://discord.com/channels/732335336448852018/1017492055737499658