0

I have an LZMA zip archive that I want to decompress using LZMA-JS, the issue is that the decompress method only accepts a byte array or node Buffer object and I do not know how to convert my zip file to a buffer object without loading the whole file to memory - so its best if it is some kind of read stream as the files I am trying to convert are huge.

It would be great if someone could suggest a way to create a byte array stream from zip file using Javascript - thank you so much! :)

ybs
  • 3
  • 2
  • Apparently, if you're using `lzma-native`, you can either provide a String, a Buffer or an Array directly: https://github.com/addaleax/lzma-native#api-LZMA_decompress . Other than that, you can convert the node buffer to a byte[] https://stackoverflow.com/questions/8609289/convert-a-binary-nodejs-buffer-to-javascript-arraybuffer but I really don't get the point. As long as a buffer is supported, just provide it. – briosheje Jun 10 '19 at 14:00
  • Thank you! I tried using that already but I am using Electron and I am getting binding module not found error - similar to the one here [https://github.com/addaleax/lzma-native/issues/45] and can't find a way around it so I am looking for other possible approaches – ybs Jun 11 '19 at 07:50
  • This is a node module that relies on gyp, so you should be using that on the "server" side of electron, in the `main` context (**not** the renderer context). Are you doing that already? – briosheje Jun 11 '19 at 08:22
  • No, I am not using it on the main context - but in my node_modules folder, I cant even find the binding file for Electron. Is that expected behaviour? – ybs Jun 11 '19 at 08:43
  • @briosheje I tried it in the main context and I still get the same error: Error: Cannot find module '\node_modules\lzma-native\binding-v4.0.5-electron-v5.0-win32-x64\lzma_native.node'. Would you happen to have any other suggestions on fixing this? Thank you! – ybs Jun 11 '19 at 08:57

1 Answers1

0

just an update for everyone who has the same issue. I ended up using 7zip-min (https://www.npmjs.com/package/7zip-min) to get around this issue. Hope that helps! :)

ybs
  • 3
  • 2