Hi Kouga,
I developed the multi-file download widget and will look into this issue, thank you for reporting. I will keep you posted and update the widget in the marketplace if necessary.
Kind regards,
Allard
I also needed multiple file download. For this I created a simple JavaScript action that can do the trick:
// This file was generated by Mendix Studio Pro.
//
// WARNING: Only the following code will be retained when actions are regenerated:
// - the import list
// - the code between BEGIN USER CODE and END USER CODE
// - the code between BEGIN EXTRA CODE and END EXTRA CODE
// Other code you write will be lost the next time you deploy the project.
import "mx-global";
import { Big } from "big.js";
// BEGIN EXTRA CODE
export function downloadFileWithDelay(fileDoc) {
if (fileDoc.get("HasContents")) {
// get file location on server
console.dir(fileDoc);
const url = "/file?guid=" + fileDoc.getGuid() + "&target=internal";
const name = fileDoc.get("Name");
const message = "file with url:" + url + " and name " + name;
console.debug("found " + message);
// create a dummy link and append to page.
// trigger click on link to download document
// remove link again
const a = document.createElement('a');
a.href = url;
a.target = '_parent';
// use a.download if available, it prevents plugins from opening
if ('download' in a) {
a.download = name;
// Add a to the doc for click to work.
(document.body || document.documentElement).appendChild(a);
if (a.click) {
console.debug("starting download " + message);
a.click(); // trigger a click to initiate the download
}
// delete the temporary link.
a.parentNode.removeChild(a);
}
}
}
// END EXTRA CODE
/**
* A JavaScript action which facilitates a multiple file download. It needs a FileDocument list as input parameter and downloads the files.
*
* The code creates a link for every file which needs to be downloaded, automatically clicks the linking and this initiates the download of the file in the browser. After downloading the link is removed again from the DOM. For Internet Explorer a delay of 500 ms is added as that is needed for it to work in IE.
* @param {MxObject[]} fileDocumentList
* @returns {Promise.<void>}
*/
export async function JS_MultipleFileDownload(fileDocumentList) {
// BEGIN USER CODE
// iterate over file list fed from Studio Pro
fileDocumentList.forEach(fileDoc => {
if (window.document.documentMode) {
// a timeout is necessary for IE, which will otherwise only download the first file.
setTimeout(() => {
downloadFileWithDelay(fileDoc);
}, 500);
} else {
downloadFileWithDelay(fileDoc);
}
})
// END USER CODE
}