Page 1 of 1

Zip a folder and download C#

PostPosted:Fri Dec 05, 2014 1:14 pm
by p.benitez
I want to ask if there is a way/function to zip a folder and download it in C# language.

I want something like the following example but in C# language:
Code: Select all
// Destination 
File file = new File("/home/openkm/import/folderExport.zip");

// OpenKM folder contents to be exported
String fldPath = "/okm:root/Permisos de circulación/import";
 
FileOutputStream os = new FileOutputStream(file);
StringWriter out = new StringWriter();
File tmp = FileUtils.createTempDir();
RepositoryExporter.exportDocuments(null, fldPath, tmp, false, false, out, new TextInfoDecorator(fldPath));
ArchiveUtils.createZip(tmp, "import", os);
org.apache.commons.io.FileUtils.deleteDirectory(tmp);
IOUtils.closeQuietly(out);
os.flush();
os.close();

Re: Zip a folder and download C#

PostPosted:Mon Dec 08, 2014 11:19 am
by jllort
You can find some Java code in com.openkm.servlet.frontend.DownloadServlet.java where is take in consideration the folder download from zip. In this kind of scenarios are several problems, some folders can contains a huge number of documents, in this cases is not good idea live downloading, better packaging in background and then send a mail. Here the best will be implemented a rest method for doing it. I suggest take a look at com.openkm.ws.rest.* and for example in FolderService I think will be good place for doing it. Obviously this feature need to extend the actual source code. I think this could be interesting feature for more people if you provide any patch or similar we will include in source code.