mruoss
:zip.foldl() returns a :data_error when calling the GetBin function
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!
Most Liked
crockwave
There’s a typo in your example. It should be:
:zip.unzip(String.to_charlist("path/to/my.zip"), [:memory])
1
Popular in Questions
What is the proper way to load a module from a file in to IEX?
In the python world, doing something like this pretty standard:
from ....
New
Hi all,
Trying to get some more clarity over utc_datetime and naive_datetime for Ecto:
https://hexdocs.pm/ecto/Ecto.Schema.html#module-...
New
I have followed this StackOverflow post to install the specific version of Erlang.
And When I am running mix ecto.setup then getting fol...
New
Hi, I’m using Ubuntu 18.04 and after updating to OTP-24.0 yesterday i have this warning when I run “mix local.hex”:
14:57:30.512 [warn] ...
New
Hey guys.
I'm new to elixir and im really stocked about it. But I ran into a bit of problem - I need to convert a date sting, for examp...
New
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
To simplify some tasks at work, I wrote and published this package yesterday. It’s a simple macro that enables Access behaviour on struct...
New
Can someone explain the settings of pool_size of Ecto in config file? and what is the recommend size?
Thanks
New
In AR this is so simple
@articles = current_user.articles
How to do in Ecto?
def index(conn, _params) do
current_user = conn.assig...
New
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
Other popular topics
Hello!
tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability.
After spen...
New
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
I couldn’t find any guides that worked well with Phoenix 1.6.0 and esbuild. I hope this helps people test the waters and eases you into t...
New
Hi folks,
Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
New
I am trying to figure out how Mix knows whether the environment is test, dev, or prod -- where is this set?
Thanks.
New
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? https://hexdocs.pm/ecto/Ecto.Repo.h...
New
Hey all,
I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
Hi everyone,
One of the features added to Elixir early on to help integration with Erlang code was the idea of overridable function defi...
New
Hi everyone!
I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New







