Compress a collection to a zip folder

Issues related to W3C XQuery.
jon
Posts: 7
Joined: Thu Mar 06, 2014 9:14 pm

Compress a collection to a zip folder

Post by jon »

Hi guys,

I use eXist 2.2RC1 for this project.
I need to archive the contents of a collection (two .doc and a .vbs files) to a zip file using xQuery.
After some research, I found out about two functions that could help me out:
- compression:zip()
- response-stream-binary()
Now, the first function apparently enables us to zip either a set of entries or a collection to a zip file. I'm not sure if the second one is useful or not but since it enables us to specify the mimetype and the output name, I thought it might be.
The problem is that I can't seem to find how to indicate the target location of the output zip folder. As a result, the zip never gets created as a physical folder. I can display what seems to be the output stream using the response:stream binary() function but I actually have to store the zip file somewhere on the database.

This is what I've been doing so far:

Code: Select all


let $collection := "/db/apps/sample" (: path to the collection I want to zip :)
return (
compression:zip(xs:anyURI($collection), true()), (: just using compression:zip :)
response:stream-binary(compression:zip(xs:anyURI($collection), true()), "application/zip", "test.zip")(: using response:stream-binary and compression:zip :)
Does any of you have an idea how to proceed, or maybe an alternative to this?
Radu
Posts: 9044
Joined: Fri Jul 09, 2004 5:18 pm

Re: Compress a collection to a zip folder

Post by Radu »

Hi,

You should consider finding an Exist users list and asking the question there. We do not use Exist that much internally so we are not familiar with all its XQuery capabilities.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply