• Zip a folder and download C#

  • He we will discuss about how to make customization and improvement to the OpenKM source code.
He we will discuss about how to make customization and improvement to the OpenKM source code.
Forum rules: Please, before asking something see the documentation wiki or use the search feature of the forum. And remember we don't have a crystal ball or mental readers, so if you post about an issue tell us which OpenKM are you using and also the browser and operating system version. For more info read How to Report Bugs Effectively.
 #30646  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();
 #30659  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.

About Us

OpenKM is part of the management software. A management software is a program that facilitates the accomplishment of administrative tasks. OpenKM is a document management system that allows you to manage business content and workflow in a more efficient way. Document managers guarantee data protection by establishing information security for business content.