How to unzip a file to process further in a MF?

Hi guys   I am retrieving an xml in a zip file from an endpoint. Zip is in, but need to be unzipped. Find other post with an example java code, but unfortunately this wasnt working for me.   EDIT 1: In Eclipse I see still an error indicating that it could not resolve "            ImportFile zipEntryDocument = new ImportFile(getContext());   Could anyone correct my java code or give other working solutions to unzip a file pls?   // This file was generated by Mendix Modeler. // // 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. // Special characters, e.g., é, ö, à, etc. are supported in comments. package ftpconnector.actions; import com.mendix.core.Core; import com.mendix.systemwideinterfaces.core.IContext; import com.mendix.webui.CustomJavaAction; import com.mendix.systemwideinterfaces.core.IMendixObject; import; import; import java.util.ArrayList; import java.util.HashMap; import; import; import; public class Unzip_File extends CustomJavaAction<java.lang.Boolean> { private IMendixObject __zipfile; private ftpconnector.proxies.ImportJob zipfile; private IMendixObject __ImportFile; private ftpconnector.proxies.ImportFileDocument ImportFile; public Unzip_File(IContext context, IMendixObject zipfile, IMendixObject ImportFile) { super(context); this.__zipfile = zipfile; this.__ImportFile = ImportFile; } @Override public java.lang.Boolean executeAction() throws Exception { this.zipfile = __zipfile == null ? null : ftpconnector.proxies.ImportJob.initialize(getContext(), __zipfile); this.ImportFile = __ImportFile == null ? null : ftpconnector.proxies.ImportFileDocument.initialize(getContext(), __ImportFile); // BEGIN USER CODE ZipInputStream zis = new ZipInputStream(Core.getFileDocumentContent(getContext(), zipfile.getMendixObject())); ZipEntry ze = zis.getNextEntry(); while(ze!=null){ String filename = substringAfterLast(ze.getName(), "/"); ImportFile zipEntryDocument = new ImportFile(getContext()); // set attributes zipEntryDocument.setName(filename); // use intermediate memory stream because storeFileDocumentContent will close the zis stream. ByteArrayOutputStream baos = new ByteArrayOutputStream(); IOUtils.copy(zis, baos); Core.storeFileDocumentContent(this.getContext(), zipEntryDocument.getMendixObject(), new ByteArrayInputStream(baos.toByteArray())); zipEntryDocument.commit(); ze = zis.getNextEntry(); } zis.closeEntry(); zis.close(); // END USER CODE } /** * Returns a string representation of this action */ @Override public java.lang.String toString() { return "Unzip_File"; } // BEGIN EXTRA CODE public static String substringAfterLast(String str, String separator) { if (str.isEmpty()) { return str; } if (separator.isEmpty()) { return str; } int pos = str.lastIndexOf(separator); if (pos == -1 || pos == (str.length() - separator.length())) { return str; } return str.substring(pos + separator.length()); } // END EXTRA CODE }  
1 answers

Try this module. I've created zip and unzip actions that you can use directly as microflow actions: