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
Okay, I'm having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I'm sure I'...
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 am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
How to set Jason to encode all fields in ecto schema, I don’t care about security and implementing only is taking long list of attributes...
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
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
I’m trying to make a websocket server in Phoenix or raw Elixir. I heard about gun, I think I could use cowboy, but since I’m not that sma...
New
Hi guys, nice to meet you to the whole forum, I’m new here, I’m trying to configure visual studio code for elixir, right now the intellis...
New
Sometimes I want to check if the input into a function is not a blank string.
My first approach:
defmodule Example do
def do_stuff(s...
New
I am trying to run a deploy with docker and I successfully runned with this command:
docker build -t romenigld/blog-prod .
but when I t...
New
Other popular topics
Update:
How to use the Blogs & Podcasts section
You can post links to your blog posts or podcasts either in one of the Official Blog...
New
Hi! May someone helps me, please!
I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
New
Hello, I get Persian date from my client and convert it to normal calendar like this:
def jalali_string_to_miladi_english_number(persi...
New
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
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 want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
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
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine)
This is a plugin that adds support for Elixir to JetBrains IntelliJ...
New
Hi,
I'm quite new in Elixir and I'm trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and ...
New
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch.
This project took far...
New







