Try to stream the file in handler.
This commit is contained in:
@@ -123,7 +123,7 @@ impl VideoPort for LibraryItemAdapter {
|
||||
id: video.id,
|
||||
name: video.name,
|
||||
format: AVI,
|
||||
file: Box::new(TokioVideoFile::new(&video_file_path).map_err(|_| VideoError::FileReadingTechnicalIssue)?)
|
||||
file: Box::new(TokioVideoFile::new(&video_file_path))
|
||||
};
|
||||
|
||||
Ok(result)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use std::any::Any;
|
||||
use std::fs::File;
|
||||
use std::io::{Error, ErrorKind};
|
||||
use tokio::fs::File;
|
||||
use uuid::Uuid;
|
||||
use lumiere_domain::video::model::library_item::{LibraryItem, LibraryItemType, LibraryRawItem};
|
||||
use lumiere_domain::video::model::video::VideoFile;
|
||||
@@ -10,10 +10,10 @@ pub struct TokioVideoFile {
|
||||
}
|
||||
|
||||
impl TokioVideoFile {
|
||||
pub fn new(file_path: &String) -> Result<Self, Error> {
|
||||
let rt = tokio::runtime::Runtime::new()?;
|
||||
let file = rt.block_on(async { File::open(file_path).await })?;
|
||||
Ok(Self { file })
|
||||
pub fn new(file_path: &String) -> Self {
|
||||
Self {
|
||||
file: File::open(file_path).expect(format!("Failed to open file {file_path}").as_str())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user