Reputation: 445
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?
Upvotes: 4
Views: 1251
Reputation: 10663
You can also do whole thing in one step:
File.write "/path/to/file.gzip", "test", [:compressed]
Upvotes: 8
Reputation: 20024
You need one more step: close the file so that any buffered data gets written:
File.close io_device
Upvotes: 6