项目作者: subvisual

项目描述 :
A tiny tiny Elixir library to stream big big files
高级语言: Elixir
项目地址: git://github.com/subvisual/http_stream.git
创建时间: 2019-09-04T15:30:27Z
项目社区:https://github.com/subvisual/http_stream

开源协议:ISC License

下载


HTTPStream

Build

HTTPStream is a tiny, tiny package that wraps HTTP requests into a Stream so
that you can manage data on the fly, without keeping everything in memory.

Downloading an image:

  1. HTTPStream.get(large_image_url)
  2. |> Stream.into(File.stream!("large_image.png"))
  3. |> Stream.run()

Streaming multiple images into a ZIP archive (using zstream)

  1. [
  2. Zstream.entry("a.png", HTTPStream.get(a_url))
  3. Zstream.entry("b.png", HTTPStream.get(b_url))
  4. ]
  5. |> Zstream.zip()
  6. |> Stream.into(File.stream!("archive.zip"))
  7. |> Stream.run()

Table of Contents

Installation

First, you need to add http_stream to your list of dependencies on mix.exs:

  1. def deps do
  2. [
  3. {:http_stream, "~> 1.0.0"},
  4. # if using the Mint adapter:
  5. {:castore, "~> 0.1.7"},
  6. {:mint, "~> 1.1.0"}
  7. # if using the HTTPoison adapter:
  8. {:httpoison, "~> 1.7.0"}
  9. ]
  10. end

HTTPStream comes with two adapters: Mint and HTTPoison.
By default Mint is configured but you need to include it in your dependencies.

To use HTTPoison, set in your config/config.exs:

  1. config :http_stream, adapter: HTTPStream.Adapter.HTTPoison

That’s it! For more intricate API details, refer to the documentation.

Development

If you want to setup the project for local development, you can just run the
following commands.

  1. git clone git@github.com:subvisual/http_stream.git
  2. cd http_stream
  3. bin/setup

PRs and issues welcome.

Contributing

Feel free to contribute!

If you found a bug, open an issue. You can also open a PR for bugs or new
features. Your PRs will be reviewed and subjected to our styleguide and linters.

All contributions must follow the Code of Conduct
and Subvisual’s guides.

About

HTTPStream is maintained with ❤️ by Subvisual.


Subvisual