TARGZIPArchiver

TARGZIPArchiver (ODC)

Stable version 0.1.0 (Compatible with ODC)
Uploaded on 20 October 2023 by OutSystems Labs
TARGZIPArchiver

TARGZIPArchiver (ODC)

Documentation
0.1.0

The code: 

This class contains two methods, MssTAR_GZIP_Zip and MssTAR_GZIP_Unzip, which are used to compress and decompress files in the tar.gz format respectively. 

TARGZIP_Compress takes a FileList object as an argument and returns a byte array containing the compressed file. It creates a MemoryStream object, then uses a GZipStream to compress it into a tar file before returning it as an array of bytes. 

TARGZIP_Uncompress takes a byte array containing the compressed file, the full path name of the file intended to be extracted, and returns a byte array containing the extracted file as well as its name and a list of all files and directories found in the compressed file. It creates a MemoryStream object from the byte array, then uses GZipStream to decompress it into a tar file before extracting the specified file from it.


Simply install and reference the server actions.

This code is a method that unzips a specific file inside a tar.gz compressed folder. It takes in a byte array of the compressed file, the full path name of the file intended to be extracted, and an output byte array for the extracted file and string for the name of the extracted file. It also has an output string for a list of all the files and directories found in the compressed file. The code creates a GZipStream from the MemoryStream of the compressed file, then creates a TarInputStream from that GZipStream. It then iterates through each entry in that TarInputStream, adding each entry's name to ListOfFiles separated by ";". If it finds an entry with the same name as FileName, it sets UnzippedFile to be that entry's contents as an array of bytes and sets UnzippedFileName to be that entry's name.

Install the demo to see the example of utilization.