-
-
Save susilolab/24ff9fd5955728575271d645fcdcb0c1 to your computer and use it in GitHub Desktop.
Decompressing a tar.gz archive in Elixir with Erlang's :erl_tar module.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @doc""" | |
| Returns a map containing all files and their contents from the compressed tar archive. | |
| """ | |
| def extract_tar_from_binary(binary) do | |
| with {:ok, files} <- :erl_tar.extract({:binary, binary}, [:memory, :compressed]) do | |
| files | |
| |> Enum.map(fn {filename, content} -> {to_string(filename), content} end) | |
| |> Map.new | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment