Zip Explorer Plugin

The Zip Explorer Plugin provides an API to create links to files inside a ZIP file. The plugin is enabled by default in XWiki Standard, so you will find it in the "xwiki.plugins" list of the xwiki.cfg file:

xwiki.plugins=\
...
  com.xpn.xwiki.plugin.zipexplorer.ZipExplorerPlugin,\
...

The source code is available on GitHub at xwiki-platform-zipexplorer

The Zip Explorer API lists the content of ZIP attachments (including XAR files) and listens to the XWiki download action in order to display the attachment content. The accepted URLs have the following syntax:

http://[...]/download/WikiPageName/zipfile.zip/FolderName/FileName.txt

Examples

Supposing you have an attachment named "xwiki-commons-component-api-6.1-javadoc.jar" which contains a Javadoc and you want to create a link to the "index.html" file, the "xwiki/2.1" syntax will be:

{{velocity}}
[[XWiki Commons - Component - API 6.1 API Javadoc>>path:$xwiki.zipexplorer.getFileLink($doc,
"xwiki-commons-component-api-6.1-javadoc.jar", "index.html")]]
{{/velocity}}

To list the content of the "xwiki-enterprise-ui-mainwiki-all-6.0.xar" file attached to the current page, use the snippet below:

{{velocity}}
#set($myXAR="xwiki-enterprise-ui-mainwiki-all-6.0.xar")
#set($plugin=$xwiki.zipexplorer)
#foreach($file in $plugin.getFileTreeList($doc, $myXAR))
 * [[$file.id>>path:$plugin.getFileLink($doc, $myXAR, $file.id)]]
#end
{{/velocity}}

The output will then be:

ZipExplorerPlugin.png

 

Related Pages

Trying to decide between Cloud and On Premise? See the comparison on the XWiki Help Center.

Search this space