How does Zlib inflate a list of bytes in Elixir?

Given the binary in Elixir that represents the compressed file, how can I pass them to Erlang zlib for bloat?

compressed = <<120, 218, 237, 125, 123, 115, 28, 71, 126, ...>> 

I tried:

 z = :zlib.open() uncompressed = :zlib.inflate(z, compressed) :zlib.close(z) 

Error returned:

 ** (ErlangError) erlang error: :einval :zlib.call/3 :zlib.inflate/2 

Expects "iodata" as an argument, so maybe I just need to convert it?

+6
source share
1 answer

After opening the zlib port, you need to call inflateInit before calling inflate :

 z = :zlib.open() :zlib.inflateInit(z) uncompressed = :zlib.inflate(z, compressed) :zlib.close(z) 
+11
source

All Articles