Download multiple files with the single click

0
I have one functionality where I want to download multiple files with a single click. I have attached the screenshot of the locic. Here iteratory OutputURL has the url of multiple file that I use in rest api. Basically Rest api will give me the file to download. For example now loop runs for 3 times, means it has created 3 files. File A, File B, File C but when it actually downlaod, it only give me file C to download.Please guide me how can I get this done.I tried multiple ofptions too:Option 1) I created custom java action to zip multiple file and output I am getting as a file.zip. After this java action when I do that download file activity from mendix, it does not download the file infact I get contact custom admin vala error. But if i remove download file activity no error.Option 2) I used marketplace module(ZipHandling by Achmea) for the zipping files. But same issue as option 1.
asked
2 answers
0

The behavior you're seeing is expected in Mendix as mendix does not support this and a microflow can only send one file download response back to the browser. If you call Download File inside a loop, only the last file processed File C in your example in your case will be downloaded.

For example:


Loop 1 → Download File A

Loop 2 → Download File B

Loop 3 → Download File C


The browser ultimately receives only the final response, so only File C is downloaded.

The recommended approach is to -

  1. Retrieve all files from your REST API
  2. Store them as FileDocument objects
  3. Create a ZIP containing all files
  4. Use a single Download File activity on the ZIP file

If you're getting a "Contact your administrator" error when downloading the ZIP, I would check:

  • Whether the ZIP entity inherits from System.FileDocument.
  • Whether the ZIP file actually contains data.
  • Whether the object passed to Download File is the ZIP FileDocument object.
  • Security/access rules on the ZIP entity.
  • Runtime logs for the actual exception (the console log usually provides more details than the generic error message).

Since you've tried both a custom Java action and the ZipHandling module and are seeing the same behavior, the issue is likely related to the generated ZIP FileDocument or the download step itself rather than the ZIP implementation.


answered
0

Hi Harsh,

Punam is right,

But for workaround it'll be better to move the download file logic to the client ( nanoflow )

and for zipping the file you can use use this code.

But this will require you to download the @zip.js from npm in your node modules.

Your package json should look like this

{

"dependencies": {

"@zip.js/zip.js": "^2.6.15",

}

}



answered