Skip to content

Commit

Permalink
Add example
Browse files Browse the repository at this point in the history
  • Loading branch information
alexdelorenzo committed Nov 10, 2020
1 parent 997bc10 commit 1aae922
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,27 @@ A stream buffer backed by `tempfile.SpooledTemporaryFile`.

[Click here to learn more about `buffer`](https://alexdelorenzo.dev/programming/2019/04/14/buffer).

[Click here for the Rust version of this library](https://gitlab.com/thismachinechills/buffers-rs).
[Click here for the Rust version of this library](https://gitlab.com/thismachinechills/buffers-rs).

# Installation
```bash
python3 -m pip install buffer==0.1.0
```

# Usage

```python3
from buffer import StreamBuffer
from requests import get


BIG_FILE = "https://releases.ubuntu.com/20.04.1/ubuntu-20.04.1-desktop-amd64.iso"


with get(BIG_FILE, stream=True) as response:
stream = response.iter_content()
length = int(response.headers['Content-Length'])

buffer = StreamBuffer(stream, length)
chunk = buffer.read(0, 1024)
```

0 comments on commit 1aae922

Please sign in to comment.