Hi again,
in case somebody is interested in the solution I post it here...
I've chosen to use JSZip for creating the zip files on server side.
Just download the library and create an .xsjslib file containing the code of the files jszip.js and jszip-deflate.js.
On the server side xsjs you can create a zip archive this way:
// create zip file var ZIP = $.mypackage.demo.lib.zip.jszip; var zipfile = new ZIP.JSZip(); zipfile.file("filename.txt", "I'm the content of the zipped file"); var content = zipfile.generate({compression: "DEFLATE"}); $.response.contentType = "Content-Type: text/plain"; $.response.setBody(content); $.response.status = 200;
On client side, initiate the creation of the archieve using an ajax request and start the download using Data URI scheme:
jQuery.ajax({ url : '/demo/services/download.xsjs?cmd=download&file=x' dataType: 'text', async : false, success: function(xhr, textStatus, error) { location.href="data:application/zip;base64,"+xhr; } });