Replies: 1 comment
-
UploadFile.file is actually a tempfile.SpooledTemporaryFile instance. This means it can be used directly as a standard file-like object, as the documentation states. You do not need to call await file.read() in order to pass it to other libraries. One detail to be aware of is the file pointer position: if the file has already been read once, the pointer will be at the end of the file. In that case you need to call file.file.seek(0) before passing it to another library.
Does this look right? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Doc mentions that
file
of aUploadFile
is a file-like that we "can pass directly to other functions or libraries that expect a "file-like" object".I'm wondering, how can I use it without using the async
read
method to explicitly awaiting for the file?Directly using the
file
attribute gives me error (presumably the file is not ready yet). I have to call the asyncread
.The doc indicates this
file
attribute is aSpooledTemporaryFile
which saves RAM. This is important if the file if very large.The critical issue of explicitly using the async
read
is it requires the entire content of the file to reside in RAM.Beta Was this translation helpful? Give feedback.
All reactions