Skip to content

Commit

Permalink
Add: Add an AsyncIterator for uploading binary content from a Path
Browse files Browse the repository at this point in the history
  • Loading branch information
bjoernricks committed Oct 25, 2022
1 parent 296c82e commit 866a5fe
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pontos/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@
DEFAULT_TIMEOUT = 1000
DEFAULT_CHUNK_SIZE = 4096


async def upload(file_path: Path) -> AsyncIterator[bytes]:
with file_path.open("rb") as f:
read = f.read(DEFAULT_CHUNK_SIZE)
while read:
yield read
read = f.read(DEFAULT_CHUNK_SIZE)


T = TypeVar("T", str, bytes)


Expand Down

0 comments on commit 866a5fe

Please sign in to comment.