peoplesoftpeoplesoft-app-engine

Zip Files using PeopleCode in Application Engine


I have a requirment to zip multiple folders inside parent folder and display the file in App Engine ouput. The folder structure in Unix File Server - Parent Folder - Folder1 (contains files) - Folder2 (contains files)

How to zip the folders and store it in parent folder using PeopleCode in AE (Final folder structure will be as follows Parent Folder -Folder1 -Folder2 -ParentFolder.Zip.

Note: Process runs on Unix Server.


Solution

  • Actually we were calling java code to zip files.

    Such as:

        &buffer = CreateJavaArray("byte[]", 18024);
        &zipStream = CreateJavaObject("java.util.zip.ZipOutputStream", CreateJavaObject("java.io.FileOutputStream", &outDir | &outZip));
        For &i = 1 To &inFiles.Len
          &zipStream.putNextEntry(CreateJavaObject("java.util.zip.ZipEntry", &inFiles [&i]));
          &inStream = CreateJavaObject("java.io.FileInputStream", &outDir | &inFiles [&i]);
          &len = &inStream.read(&buffer);
          While &len > 0;
            &zipStream.write(&buffer, 0, &len);
            &len = &inStream.read(&buffer);
          End-While;
          &zipStream.closeEntry();
          &inStream.close();
        End-For;
    
       &zipStream.close();