https://github.com/ananthakumaran/zstream
An elixir library to write and read ZIP file in a streaming fashion
https://github.com/ananthakumaran/zstream
elixir stream streaming zip zipfile
Last synced: 3 days ago
JSON representation
An elixir library to write and read ZIP file in a streaming fashion
- Host: GitHub
- URL: https://github.com/ananthakumaran/zstream
- Owner: ananthakumaran
- License: mit
- Created: 2017-11-08T17:05:59.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2025-03-29T05:07:28.000Z (about 2 months ago)
- Last Synced: 2025-04-12T14:54:56.681Z (about 1 month ago)
- Topics: elixir, stream, streaming, zip, zipfile
- Language: Elixir
- Homepage:
- Size: 385 KB
- Stars: 56
- Watchers: 3
- Forks: 16
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Zstream
[](https://github.com/ananthakumaran/zstream/actions?query=workflow%3A.github%2Fworkflows%2Fci.yml)
[](https://hex.pm/packages/zstream)
[](https://hexdocs.pm/zstream/)
[](https://hex.pm/packages/zstream)
[](https://github.com/ananthakumaran/zstream/blob/master/LICENSE)
[](https://github.com/ananthakumaran/zstream/commits/master)An Elixir library to read and write ZIP file in a streaming
fashion. It could consume data from any stream and write to any stream
with constant memory overhead.## Installation
The package can be installed by adding `:zstream` to your list of dependencies
in `mix.exs`:```elixir
def deps do
[
{:zstream, "~> 0.6"}
]
end
```## Examples
```elixir
Zstream.zip([
Zstream.entry("report.csv", Stream.map(records, &CSV.dump/1)),
Zstream.entry("catfilm.mp4", File.stream!("/catfilm.mp4", [], 512), coder: Zstream.Coder.Stored)
])
|> Stream.into(File.stream!("/archive.zip"))
|> Stream.run
``````elixir
File.stream!("archive.zip", [], 512)
|> Zstream.unzip()
|> Enum.reduce(%{}, fn
{:entry, %Zstream.Entry{name: file_name} = entry}, state -> state
{:data, :eof}, state -> state
{:data, data}, state -> state
end)
```## Features
### zip
* compression (deflate, stored)
* encryption (traditional)
* zip64### unzip
* compression (deflate, stored)
* zip64## License
Copyright (c) 2017 Anantha Kumaran
This library is MIT licensed. See the [LICENSE](https://github.com/ananthakumaran/zstream/blob/master/LICENSE) for details.