Hello
I’m trying to process a .zip
file “on-the-fly” using :zip.foldl/2
. The way I understand the documentation, this function iterates over the files inside the ZIP. In the callback I get a function GetBin
to get the content of the current file.
My Problem: When calling that function GetBin
, I get a :data_error
. Here’s the code:
iex> :zip.foldl(
fn _, _, get_bin, _ -> dbg(get_bin.()) end,
nil,
String.to_charlist("path/to/my.zip")
)
** (ErlangError) Erlang error: :data_error
:zlib.inflate_nif(#Reference<0.1295784330.1440088067.199893>, 8192, 16384, 0)
:zlib.dequeue_all_chunks_1/3
:zlib.inflate/3
:prim_zip.get_z_all/4
Just to rule out some things, this code works:
iex> :zip.foldl(
fn filename, _, _, _ -> IO.puts(filename) end,
nil,
String.to_charlist("path/to/my.zip")
)
file1
file2
file3
{:ok, :ok}
Version: IEx 1.15.4 (compiled with Erlang/OTP 26)
Does anybody know how to make this work?
Thanks!