Pack in zip archive

Currently user in my app batch-downloads many files one by one like this

for (Pair<String, String> file : files) {
    try {
                new ByteArrayDataProvider(file.getValue().getBytes("windows-1251")),
                file.getKey(), ExportFormat.OCTET_STREAM
    } catch (UnsupportedEncodingException e) {
        throw new RuntimeException("Error while reEncoding", e);

But how do I pack them all (files) in one zip and then make user download zip, preferably without temporarily storing each file in FileStorage?
I see this may be implemmented in GitHub - cuba-platform/admin-tools-addon: Interactive runtime diagnosis for CUBA applications
– I will look there but hopefully you will reply to me earlier…image


There is no CUBA specifics here, you can use commons-compress library and build single ZIP: Commons Compress – Commons Compress User Guide