mirror of
https://github.com/actix/actix-web.git
synced 2024-12-16 21:26:34 +00:00
add file chunks stream adapter
This commit is contained in:
parent
3f03af1c59
commit
c759bdef4c
2 changed files with 7 additions and 2 deletions
|
@ -33,7 +33,6 @@ mod path_buf;
|
|||
mod range;
|
||||
mod service;
|
||||
|
||||
pub use self::chunked::ChunkedReadFile;
|
||||
pub use self::directory::Directory;
|
||||
pub use self::files::Files;
|
||||
pub use self::named::NamedFile;
|
||||
|
|
|
@ -21,8 +21,9 @@ use actix_web::{
|
|||
Error, HttpMessage, HttpRequest, HttpResponse, Responder,
|
||||
};
|
||||
use bitflags::bitflags;
|
||||
use bytes::Bytes;
|
||||
use derive_more::{Deref, DerefMut};
|
||||
use futures_core::future::LocalBoxFuture;
|
||||
use futures_core::{future::LocalBoxFuture, Stream};
|
||||
use mime_guess::from_path;
|
||||
|
||||
use crate::{encoding::equiv_utf8_text, range::HttpRange};
|
||||
|
@ -527,6 +528,11 @@ impl NamedFile {
|
|||
|
||||
res.body(SizedStream::new(length, reader))
|
||||
}
|
||||
|
||||
/// Returns stream of chunks for the complete file.
|
||||
pub fn into_chunk_stream(self) -> impl Stream<Item = Result<Bytes, Error>> {
|
||||
chunked::new_chunked_read(self.md.len(), 0, self.file)
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns true if `req` has no `If-Match` header or one which matches `etag`.
|
||||
|
|
Loading…
Reference in a new issue