Skip to content

GzipFile / GunzipFile (gzip compression)

SyncJS provides two functions for gzip-based single-file compression and decompression.

NOTE

These functions are available as of Syncplify Server! v7.1.1. If you are running an older version, upgrade to v7.1.1 or later to use them.

GzipFile

ts
function GzipFile(path: string, destPath?: string): boolean;

Compresses a single file using the gzip format. When destPath is omitted, the output file is written alongside the source with a .gz extension appended (e.g. report.csv becomes report.csv.gz).

ParameterTypeRequirementExplanation
pathstringrequiredFully qualified path to the file to compress
destPathstringoptionalPath for the compressed output file. Defaults to path + ".gz"
Return valueExplanation
trueCompression succeeded
falseCompression failed (file not found, insufficient disk space, etc.)

Example

ts
// Compress with default destination name
GzipFile('/var/reports/monthly.csv');
// Creates /var/reports/monthly.csv.gz

// Compress to a specific destination
GzipFile('/var/reports/monthly.csv', '/var/archive/2026-04-monthly.csv.gz');

GunzipFile

ts
function GunzipFile(path: string, destPath?: string): boolean;

Decompresses a single gzip-compressed file. When destPath is omitted, the output path is derived from the source: the .gz extension is stripped if present (e.g. report.csv.gz becomes report.csv). If the source does not end with .gz, the suffix .out is appended to avoid overwriting the source.

ParameterTypeRequirementExplanation
pathstringrequiredFully qualified path to the .gz file to decompress
destPathstringoptionalPath for the decompressed output file
Return valueExplanation
trueDecompression succeeded
falseDecompression failed (file not found, corrupt data, etc.)

Example

ts
// Decompress with default destination name
GunzipFile('/var/archive/2026-04-monthly.csv.gz');
// Creates /var/archive/2026-04-monthly.csv

// Decompress to a specific destination
GunzipFile('/var/archive/2026-04-monthly.csv.gz', '/var/reports/monthly.csv');

NOTE

GzipFile and GunzipFile operate on a single file at a time. To compress multiple files into one archive, use Zip instead.