Created
April 21, 2019 12:29
-
-
Save nroi/d4b0716a987c46534c04eb6611b78703 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 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