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
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).
| Parameter | Type | Requirement | Explanation |
|---|---|---|---|
path | string | required | Fully qualified path to the file to compress |
destPath | string | optional | Path for the compressed output file. Defaults to path + ".gz" |
| Return value | Explanation |
|---|---|
true | Compression succeeded |
false | Compression failed (file not found, insufficient disk space, etc.) |
Example
// 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
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.
| Parameter | Type | Requirement | Explanation |
|---|---|---|---|
path | string | required | Fully qualified path to the .gz file to decompress |
destPath | string | optional | Path for the decompressed output file |
| Return value | Explanation |
|---|---|
true | Decompression succeeded |
false | Decompression failed (file not found, corrupt data, etc.) |
Example
// 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.
