you may need to store all these pdf file as filedocument in list, then use java action to download the list as zip files.
The lib you need to use are:
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.util.List;
import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream;
// input list object
private List<IMendixObject> fileList;
// the code to implement
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ZipOutputStream zipOut = new ZipOutputStream(baos);
for (IMendixObject fileObj : fileList) {
// Retrieve the name of the file
String fileName = fileObj.getValue(getContext(), "Name").toString();
// Create a new ZIP entry
ZipEntry zipEntry = new ZipEntry(fileName); zipOut.putNextEntry(zipEntry);
// Retrieve the content of the file
InputStream fileContent = Core.getFileDocumentContent(getContext(), fileObj);
// Write the content to the ZIP output stream
byte[] bytes = new byte[1024];
int length;
while ((length = fileContent.read(bytes)) >= 0) { zipOut.write(bytes, 0, length); }
fileContent.close();
zipOut.closeEntry(); }
zipOut.close();
// Convert ByteArrayOutputStream to InputStream
return new ByteArrayInputStream(baos.toByteArray());
Hi,
the common approach is to zip all files (there are several modules for zip handling available) and download the archive.
You can't download multiple files from a single microflow. It might work to loop over the downloads in a nanoflow.
regards, Fabian
Or use a JavaScript action like I shared in below forum post to trigger the multi file download:
https://forum.mendix.com/link/space/studio-pro/questions/119569