pako

I need JSZip and gzip for my web page, and JSZip has all the ingredients, but hides them in ways I can't crack

倾然丶 夕夏残阳落幕 提交于 2019-12-11 18:15:15
问题 Support for gzip in JavaScript is surprisingly weak. All browsers implement it for supporting the Content-encoding: gzip header, but there is no standard access to the gzip / gunzip function of the browser. So one must use a javascript only approach. There are some old gzip-js libraries around, but they don't seem stream-enabled and 6 years out of maintenance. Then there is pako, more actively maintained, but that also doesn't seen stream enabled if using their own distribution, so you need

gzinflate string compressed via JS

隐身守侯 提交于 2019-12-11 15:45:32
问题 I'm trying to compress a massive JS object on the client side via Pako and than get it back on the PHP-script. JS code const save_str = JSON.stringify(massive_object); const gz_str = pako.gzip(save_str, { to: 'string' }); $.post('/', {data:window.btoa(unescape(encodeURIComponent(gz_str)))}, (data)=>{ console.log(data); }, 'json'); PHP code $res = gzinflate(base64_decode($_POST['data'])); Should be quite straight-forward thing but I keep getting gzinflate(): data error . Already spent a few