Page 1 of 1

Compress a collection to a zip folder

Posted: Mon Aug 11, 2014 9:24 pm
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", "")(: using response:stream-binary and compression:zip :)
Does any of you have an idea how to proceed, or maybe an alternative to this?

Re: Compress a collection to a zip folder

Posted: Tue Aug 12, 2014 8:09 am
by Radu

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.