How can I perform a zip compression that outputs binary, not a zip file?

647 views Asked by At

Use-case

  • Compress a String to a binary ZIP blob
  • The resulting ZIP should not resemble a ZIP file, but rather, result the result RAW binary stream ( should not have the .ZIP file folders/file envelope

Text String -> Compress -> RAW binary Blob

I was reading about JSZip that seems quite comprehensive, but, it seems the output is always a ZIP file ( including the folder/files envelope ) where what I needed is the RAW binary blob for the iput string ( not associated to any file name ).

Is there any way to achieve that using Client Side JavaScript ? ( using JSZip or others )

1

There are 1 answers

0
Mark Adler On BEST ANSWER

Use zlib. zlib.Deflate will compress the data to a zlib stream. A zlib stream is the deflate compressed data with a two-byte header and a four-byte integrity check trailer. Six bytes is a tiny amount for the assurance of an integrity check, but if you want to even get rid of those, then you can use zlib.DeflateRaw.