mafintosh / tar-stream

tar-stream is a streaming tar parser and generator.
MIT License
406 stars 92 forks source link

how to zip file after tar #73

Closed cwtuan closed 1 year ago

cwtuan commented 7 years ago
      const stream = tar.pack() 
      stream.entry({ name: '/foo/test.txt' }, 'hello');
      stream.finalize();

Now I have a tar stream, how to gz it?

ralphtheninja commented 7 years ago
const z = zlib.createGzip()
stream.pipe(z)
cwtuan commented 7 years ago
const z = zlib.createGzip()

const stream = tar.pack() 
stream.entry({ name: '/foo/test.txt' }, 'hello');
stream.pipe(z)
stream.finalize();

is it right?

cwtuan commented 7 years ago

@ralphtheninja Could you please provide more detail? I save the file into disk and try to unzip tar -zxvf files.tar.gz It seems zlib doesn't work.

gzip: stdin: not in gzip format
tar: Child returned status 1
tar: Error is not recoverable: exiting now

The file is still just a tar file becausetar -xvf files.tar.gz success.

Thanks for your help.

ralphtheninja commented 7 years ago

Mind sharing the code you have written this far?

abrinckm commented 4 years ago

@cwtuan I have written a solution here: https://github.com/mafintosh/tar-stream/issues/24