#2759 How to set zip file compression level?

Ilove:= Wed 26 Jun

I played a bit with deflateOutStream but it go to nowhere. I want to set level to 9 for example zip file myzip.zip, that all file added to this zip will be compressed with level 9. Please help.

SlimerDude Wed 26 Jun

I'm a bit confused by your question, as Zip.deflateOutStream() just compresses a stream of data - nothing to do with entries in a Zip file.

To compress a single file using deflate compression, try this:

out   := `output.df`.toFile.out
dfOut := Zip.deflateOutStream(out, ["level":9])



Ilove:= Wed 26 Jun

So how to set zip.write(...) compression level to 9? By default it compression level is very low. I read the api doc many time but found nothing regarding it, only about deflate out stream :(

Ilove:= Wed 26 Jun

Just curious. How to decompress deflate out stream above? What is the usage of it if not with zip file?

SlimerDude Mon 1 Jul

There is no means to set the compression level when managing .zip files - I've not noticed the default level being particularly low.

Compressing / decompressing streams is useful when performing compression yourself, for example, when sending or receiving data over HTTP.

To deflate files, use the Zip.deflateInStream() method, something like:

in   := `input.df`.toFile.in
dfIn := Zip.deflateInStream(in)
data := dfIn.readAllBuf


Login or Signup to reply.