mruoss
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!
Trending in Questions
Hello!
Suppose you are building workflow (order / task / payment) processing system with the following requirements:
Each workflow con...
New
I’m in search of an Elixir library that offers PDF generation capabilities similar to Ruby’s Prawn. While there have been discussions abo...
New
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
Before I dive in myself, did anyone successfully sprinkle Hologram into their existing LiveView app?
Looking for hints regarding:
Addi...
New
Hi all, I wanted to ask how the community is dealing with post-release steps.
Today we have Ecto migrations, which make sure that the db...
New
Kia ora,
We have been using elixir-google-api to connect to Google Drive. However, with the updates to Tesla due to CVEs this is now bro...
New
I am using Oban and occasionally, shortly after a deployment, a handful of jobs can fail because of dependency on other parts of the syst...
New
Other Trending Topics
Lightning Talk: Jacob Swanner - Put your Scaller (Named Correctly) | ElixirConf US 2025
https://www.youtube.com/watch?v=dqqZSSxs-MA
Co...
New
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #blog-post
- #phoenix_html
- #iex
- #graphql
- #genstage
- #ai
- #elixirconf-us
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex










First 6 of 6 Posts
al2o3cr
I’m not sure that actually rules much out - the directory is separate from the data in an zip file, so that version isn’t trying to read most of the file.
mruoss
Gotcha. But this works, too:
olivermt
Edit: need more coffee, thought you were MAKING zips
moogle19
It looks like it depends on the zip if this works or not.
If I create a zip with the build-in macOS function, I get the same error.
If I use
zipfrom the terminal, it works.This seems to be a problem in the macOS Archive Utility.
mruoss
Hmm… possible. Although I would be surprised if my zip was created on Mac OS. But I don’t know for sure.
crockwave
There’s a typo in your example. It should be:
:zip.unzip(String.to_charlist("path/to/my.zip"), [:memory])