xdmp.zipCreate( manifest as Array|Node, nodes as Array|Sequence ) as binary()
Create a zip file from a list of nodes.
While you can create a zip file of encrypted content,
xdmp.zipCreate
does not have the
capability to encrypt the content to be zipped.
The
'part'
objects in the
manifest should contain relative paths so the zip file can be
unpacked into its own directory; do not start the path with a
forward slash or a backslash.
To support creating Open
Container Format archives for the EPUB format,
xdmp.zipCreate
will not
compress the first part if it is named "mimetype".
const zip = xdmp.zipCreate( [{ 'path': '/mydoc.xml' }, { 'lastModified': '2018-10-02T09:50:00', 'path': '/mypicture.jpg' } ], [cts.doc('/mydoc.xml'), cts.doc('/mypicture.jpg')]); xdmp.save('/tmp/myzip.zip', zip); // Creates a zip archive that includes the documents "/mydoc.xml" // and "/mypicture.jpg", then saves that to the filesystem.
// the "mimetype" file will not be compressed, so as to support // the EPUB format var nb = new NodeBuilder(); const mimedoc = nb.startDocument() .addText('application/epub+zip') .endDocument() .toNode(); const zip = xdmp.zipCreate( [{path:'mimetype'}, {path:'META-INF/container.xml'}, {path:'OEBPS/content.opf'}, {path:'OEBPS/content.pdf'} ], [mimedoc, cts.doc('/my-doc/container.xml'), cts.doc('/my-doc/content.opf'), cts.doc('/my-doc/content.pdf') ]); xdmp.save('/tmp/mydoc.epub', zip); // Creates a zip archive that meets the OCF specification, // then saves that to the filesystem.