MartinElvar

MartinElvar

Decompressing file with Zstd

I’m trying to decompress a zstd compressed file using the Elixir, and the library GitHub - chenzhuoyu/elixir-zstd: Elixir binding of the Zstandard library · GitHub

I’ve tried the following

    {:ok, content} = File.read("myfile")
    <<header :: binary-size(12), remainder :: binary>> = content

    {:ok, orig} = ExZstd.simple_decompress(remainder)

->  ** (MatchError) no match of right hand side value: {:error, 'Unable to determain decompressed size'}

There er no problems when running the zstd command from the terminal.

I’ve also trying the streaming solution, found in the test example.

https://github.com/chenzhuoyu/elixir-zstd/blob/master/test/ex_zstd_test.exs

But i fail to see how i get the tail, when the data is from a file, and not a compression stream.

Any who can help me out, or should i simply resort to calling the zstd command directly from my code.

Most Liked

sribe

sribe

I don’t know this library, but I bet you need to pass the whole file contents in rather than discarding the header.

MartinElvar

MartinElvar

Yes, i’ve have tried writing remainder to a file, and then decompress it with zstd -d myfile.zst no problem. Maybe it’s version mismatch.

OvermindDL1

OvermindDL1

It’s possible, it doesn’t look like that library links a built in zstd library but rather just whatever is available on the system. Maybe try a little hoist program to confirm that, like python with ffi for a quick link and test or so?

Where Next?

Popular in Questions Top

rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
komlanvi
Hi everyone, I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New

Other popular topics Top

Qqwy
Update: How to use the Blogs &amp; Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3271 130286 1222
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 49084 226
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
romenigld
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
AstonJ
Posting this to see if we can make things easier for people to get into Neovim. If you use Neovim and have a favourite distro please let ...
New

We're in Beta

About us Mission Statement