It's possible that in some scenarios you should compress as a ZIP and send a document through a WebService in base64. For achieve this we can use UDF and some libraries.
The UDF will be this:
public String invoice2zip(String invoice, String filename, Container container) throws StreamTransformationException{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ZipOutputStream zos = new ZipOutputStream(baos);
BASE64Encoder encoder = new BASE64Encoder();
String encoded = "";
try{
zos.putNextEntry(new ZipEntry(filename));
zos.write(invoice.getBytes());
zos.close();
encoded = encoder.encode( baos.toByteArray());
}catch(Exception e){
return "";
}
return encoded;
}
We need to import a library for Base64 encoding: sun.misc.BASE64Encoder
Mapping:
UDF:
Regards