pieroxy / lz-string

LZ-based compression algorithm for JavaScript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[QUESTION]: is the output of compressToUint8Array a valid .lz file?

luca-viggiani opened this issue · comments

Hi, can the output of compressToUint8Array be written to a valid format that can then be uncompressed by any external utility?

For example, I'm sending the output of compressToUint8Array to my web server that writes it to a file like this:

const lz = LZString.compressToUint8Array("something special");
const data = new Blob([lz], { type: "application/lzip"});
// must use multi party form data to prevent troubles with large files
const fd = new FormData();
fd.append(filePath, data);
var xhr = new XMLHttpRequest();
xhr.open("PUT", "somewhere/over/the/rainbow/file.lz", true);
xhr.send(fd);

data is correctly received and saved to a file.lz, however if I try, form linux, to uncompress (e.g. lz file.lz) it tells it's not a valid archive. So I'm wondering if there's a proper extension or way to save in order to be able to decompress without your lib (like for example with .gz files: gzip -d file.gz). To be clear, I'm not expectig it to be a .tar archive, just a compressed single file and be able to uncompress whit from command line for example.

This library uses its own compression algorithm and format. It is not compatible with gzip in any way. You can install lz-string from npm (Look at the readme.md) and uncompress your data server side.