Code Monkey home page Code Monkey logo

http_stream's Introduction

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:

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

Streaming multiple images into a ZIP archive (using zstream)

[
  Zstream.entry("a.png", HTTPStream.get(a_url))
  Zstream.entry("b.png", HTTPStream.get(b_url))
]
|> Zstream.zip()
|> Stream.into(File.stream!("archive.zip"))
|> Stream.run()

Table of Contents

Installation

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

def deps do
  [
    {:http_stream, "~> 1.0.0"},

    # if using the Mint adapter:
    {:castore, "~> 0.1.7"},
    {:mint, "~> 1.1.0"}

    # if using the HTTPoison adapter:
    {:httpoison, "~> 1.7.0"}
  ]
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:

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.

git clone [email protected]:subvisual/http_stream.git
cd http_stream
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

http_stream's People

Contributors

frm avatar farhadi avatar junaid1460next avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.