示例数据可以是found here allCountries.zip,它是邮政编码数据库表格geonames.org。
我正在运行此代码,
const zlib = require('zlib');
const fs = require('fs');
const zip = fs.readFileSync('/tmp/allCountries.zip');
zlib.gunzip(zip, unzipData => console.log(unzipData) );
我收到了这个错误,
{ Error: incorrect header check
at Zlib._handle.onerror (zlib.js:356:17) errno: -3, code: 'Z_DATA_ERROR' }
我也尝试过zlib.unzip
,它会返回相同的错误,zlib.unzipSync
就是这样,
zlib.unzip(zip, unzipData => console.log(unzipData) );
返回此堆栈转储,
zlib.js:536
throw error;
^
Error: incorrect header check
at Zlib._handle.onerror (zlib.js:356:17)
at Unzip.Zlib._processChunk (zlib.js:526:30)
at Object.<anonymous> (/tmp/test.js:6:6)
at Module._compile (module.js:574:32)
at Object.Module._extensions..js (module.js:583:10)
at Module.load (module.js:491:32)
at tryModuleLoad (module.js:450:12)
at Function.Module._load (module.js:442:3)
at Module.runMain (module.js:608:10)
at run (bootstrap_node.js:382:7)
我正在使用v7.0.0-test2016100609987d242b
,但我已经确认这与v6.7.0
的结果相同。此档案会使用gunzip -c
和unzip
正确摘录。
$ unzip -v ./allCountries.zip
Archive: ./allCountries.zip
Length Method Size Cmpr Date Time CRC-32 Name
-------- ------ ------- ---- ---------- ----- -------- ----
96309121 Defl:N 12668483 87% 2016-10-10 03:05 0666ed3f allCountries.txt
-------- ------- --- -------
96309121 12668483 87% 1 file