Given a binary in Elixir which represents a compressed file, how can I pass them to Erlang's zlib to inflate?
compressed = <<120, 218, 237, 125, 123, 115, 28, 71, 126, ...>>
I have tried:
z = :zlib.open()
uncompressed = :zlib.inflate(z, compressed)
:zlib.close(z)
Error returned is:
** (ErlangError) erlang error: :einval
:zlib.call/3
:zlib.inflate/2
Expects an "iodata" as an argument, so maybe I just need to convert it?
After opening the zlib port, you need to call inflateInit
on it before calling inflate
:
z = :zlib.open()
:zlib.inflateInit(z)
uncompressed = :zlib.inflate(z, compressed)
:zlib.close(z)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With