You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The send_file example currently reads the entire file into memory. It would be better to stream the file, to show how to do so in case of large files.
Instead of using tokio::fs::read(), we can use `tokio::fs::File::open()``.
Then, the File can be wrapped in a tokio_util::io::ReaderStream.
That stream can be converted into a body with http_body_util::StreamBody.
But the "not found" body is not a stream, it is still a Full<Bytes>. So, to be able to return both, the final body type needs to a http_body_util::combinators::BoxBody<Bytes, std::io::Error>. You can use http_body_util::BodyExt::boxed() to create one.
The text was updated successfully, but these errors were encountered:
The
send_file
example currently reads the entire file into memory. It would be better to stream the file, to show how to do so in case of large files.tokio::fs::read()
, we can use `tokio::fs::File::open()``.File
can be wrapped in atokio_util::io::ReaderStream
.http_body_util::StreamBody
.Full<Bytes>
. So, to be able to return both, the final body type needs to ahttp_body_util::combinators::BoxBody<Bytes, std::io::Error>
. You can usehttp_body_util::BodyExt::boxed()
to create one.The text was updated successfully, but these errors were encountered: