shelfio / libreoffice-lambda-layer

MIT License
108 stars 21 forks source link

How to unpack lo.tar.br using brotli? #43

Closed Jun711 closed 2 years ago

Jun711 commented 2 years ago

Hi, I tried to use Nodejs brotli to unpack the lo.tar.br file but I am not sure how to use it. After zlib.brotliDecompress, the tar.br file is still not unpacked.
Could you please provide an example? Thank you

What I tried

const libreOfficePacked = fs.readFileSync('/tmp/lo.tar.br')
zlib.brotliDecompress(libreOfficePacked)

https://nodejs.org/api/zlib.html#zlibbrotlidecompressbuffer-options-callback

zlib.brotliDecompress(buffer[, options], callback)

From brotli npm doc,

// decode a buffer where the output size is known
brotli.decompress(compressedData, uncompressedLength);

// decode a buffer where the output size is not known
brotli.decompress(fs.readFileSync('compressed.bin'));
vladholubiev commented 2 years ago

Here is the example: https://github.com/shelfio/aws-lambda-libreoffice/blob/master/src/unpack.ts