Zip/Download files

1
Hi, I tried to add a button that download multiple files (1 excel report and some photos) in the same time. In order to do that, I tried to zip these files, with differents solutions that I found, but for the moment nothing works. I first tried to download the module "Create Zip" on the app Store, and call the Java action "ZipDocuments" in my microflow. It takes 2 parameters, a file document previously created that will contain the files zipped and a List of file documents that contains my 3 files. I created these 2 objects, I added the files to the list and I put the right parameters in the Java action. But when I test it, nothing is downloaded.  I tried to see with breakpoints if the file document that should contain the zip was empty, but no, after the java action call it has contents and a size that seems to be well.   Afterwards, I tried a second way, that I found over here : https://community.mendix.com/link/questions/6444, (code here : https://pastebin.com/PkJJCxZE). This link gave a code that was similar but not exactly the same, this time there is a return object that is the zip file. I created the java action with the right parameters, I called the it, then when I try to download the returned file, nothing is downloaded again. And I have no errors. Did someone manage to make it work ?  I put a picture of my microflow in order that it is clearer. Thank you in advance.  
asked
4 answers
5

Try using an entity in your own domain model, inherited from System.FileDocument, and not System.FileDocument itself, since you can't put access rules on FileDocument. Create an entity and in 'Generalization', pick System.FileDocument. Configure access rules per user role as needed, then try again. Where a java action expects a FileDocument object, you can put your entity.

answered
2

Indeed like Martin Koelewijn says; do not use the FileDocument Entity directly. See this How-to about doc generation. The part about the Entity applies to your case as well https://docs.mendix.com/refguide/how-to-create-your-own-documents

The reason the download is blocked is that the user doesn't have read rights at Entity level. So configuring the entity access will do the trick

answered
1

Thanks to everyone, by creating a new entity called zip, linked to the entity that I was wowrking on to download, it now works perfectly.

I had also to change in the java action the input file, from a "System.document" type to my new Entity one.

I did it with the module "Create Zip".

answered
0

Maybe a stupid question, is the download being blocked by your browser? 

answered