Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to write to gzip file from elixir code

Tags:

gzip

elixir

I would like to write gzip file from elixir code.

I tried to following code, but it doesn't work well.

io_device = File.open!("/path/to/file.gzip", [:write, :compressed])
IO.write(io_device, "test")

IO.write returns :ok, but, /path/to/file.gzip is empty.

How can I write to gzip file?

like image 825
tamagohan2 Avatar asked Dec 09 '22 00:12

tamagohan2


1 Answers

You can also do whole thing in one step:

File.write "/path/to/file.gzip", "test", [:compressed]
like image 61
Kabie Avatar answered Dec 17 '22 17:12

Kabie