How To export Files into ZIP from PEGA repository
Hi Team We have a couple of CSV files on our pegacloudrepository, now we want to be able to download this files as we please. The download part is cover, but we want to compress the files into a Zip, so we only get one file. I've tried this code:
Hi Team We have a couple of CSV files on our pegacloudrepository, now we want to be able to download this files as we please. The download part is cover, but we want to compress the files into a Zip, so we only get one file. I've tried this code:
java.lang.StringBuilder sb = new java.lang.StringBuilder();
char sep = PRFile.separatorChar;
String FileName = tools.getParamValue("FileName");
String TmpDir = pega.getSystemSettings().getFSSetting("initialization/explicittempdir", null, true, false);
String FullPath = TmpDir + "\\StaticContent\\global\\ServiceExport";
int BUFFER = 2048;
try {
java.io.BufferedInputStream origin = null;
String zipfileName = FullPath + sep + "SystemInfo.zip";
java.io.File f = new java.io.File(zipfileName);
f.createNewFile();
java.io.FileOutputStream dest = new java.io.FileOutputStream(f);
java.util.zip.ZipOutputStream out = new java.util.zip.ZipOutputStream(new java.io.BufferedOutputStream(dest));
byte data[] = new byte[BUFFER];
String files[] = {"MensOutboundLineas_20231204T145311.109 GMT.xlsx"};
for(int i=0; i<files.length; i++){
java.io.FileInputStream fi = new java.io.FileInputStream(FullPath + sep +files[i]);
origin = new java.io.BufferedInputStream(fi, BUFFER);
java.util.zip.ZipEntry entry = new java.util.zip.ZipEntry(files[i]);
out.putNextEntry(entry);
int count;
while((count = origin.read(data, 0,
BUFFER)) != -1)
{
out.write(data, 0, count);
}
origin.close();
}
out.close();
}
catch (Exception e)
{
oLog.error(e.getStackTrace());
}
But I think the PATH for the files is being set incorrectly. How can I past my desired export path to this code? Path: pegacloudrepository/XXX Thanks