addaleax / lzma-native

Node.js interface to the native liblzma compression library (.xz file format, among others)
MIT License
105 stars 37 forks source link

Unknown file format when using normal XZ file #75

Closed Kitsumi closed 5 years ago

Kitsumi commented 5 years ago

I'm trying to decompress data from the reddit comment archives in a stream, but it doesn't seem to work...

let file = fs.createReadStream(currentFile, {flags: "r", encoding: "utf-8"});
stream = lzma.createDecompressor();
file.pipe(stream);

I checked the file, and it downloaded properly, and I can also extract it with unxz file and xz -d file

addaleax commented 5 years ago

@Kitsumi Using encoding: "utf-8" makes Node.js read the file as UTF-8 text, which is not what you want when reading a binary file. Just leave out the encoding: bit and things should work fine. :)

Kitsumi commented 5 years ago

Oof, you're right, I didn't see that at first! I guess doing code super late at night isn't a good idea. Thanks so much.