This is the updated piece of code: -
public static byte[] zipFiles(String... uuids) throws IOException,
LinkException, RepositoryException, ZipException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
BufferedOutputStream bos = new BufferedOutputStream(baos);
ZipOutputStream zos = new ZipOutputStream(baos);
try {
for (String uuid : uuids) {
Node fileNode =
NodeUtil.getNodeByIdentifier(ApplicationFunctions.LITERATURE_WORKSPACE, uuid);
Binary binary =
fileNode.getProperty("jcr:data").getBinary();
InputStream is = binary.getStream();
ZipEntry ze = new ZipEntry(File.separator +
fileNode.getProperty("fileName").getString());
// new zip entry and copying inputstream with
file to zipOutputStream, after all closing streams
zos.putNextEntry(ze);
IOUtils.copy(is, zos);
binary.dispose();
}
} catch (Exception e) {
EtechLogger.error(FileUtil.class, "Exception in
zipFiles: " + e.getMessage());
} finally {
zos.closeEntry();
if (zos != null) {
zos.finish();
zos.flush();
IOUtils.closeQuietly(zos);
}
IOUtils.closeQuietly(bos);
IOUtils.closeQuietly(baos);
}
return baos.toByteArray();
}
--
Context is everything:
http://forum.magnolia-cms.com/forum/thread.html?threadId=14c92789-1e21-4784-8257-0b068cd04fc3
----------------------------------------------------------------
For list details, see http://www.magnolia-cms.com/community/mailing-lists.html
Alternatively, use our forums: http://forum.magnolia-cms.com/
To unsubscribe, E-mail to: <[email protected]>
----------------------------------------------------------------