Feeding request.stream
into tarfile.open(fileobj=...)
#1925
Closed
bradbeattie
started this conversation in
General
Replies: 2 comments 5 replies
-
For anyone reading after-the-fact, a solution I found was to
Not exactly elegant, but it gets the job done. |
Beta Was this translation helpful? Give feedback.
0 replies
-
anyio has some pretty good facilities for this: https://anyio.readthedocs.io/en/stable/api.html#anyio.wrap_file |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I’m looking to use Starlette’s
request.stream
from a streaming upload and feed it straight into a tarfile.open similar totarfile.open(fileobj=request.stream(), mode="r|")
.But this doesn’t work as request.stream() is an async generator and tarfile.open is expecting a file-like object (e.g. io.BufferedReader). So this understandably errors out with
Anyone have experiencing with converting an asynchronous generator to an io.BufferedReader? Or any other good way of supporting streaming uploads directly into tarfile.open?
Beta Was this translation helpful? Give feedback.
All reactions