Try to stream the file in handler.

This commit is contained in:
Florian THIERRY
2026-07-24 15:38:36 +02:00
parent f8f86eeae1
commit cef96884c6
6 changed files with 35 additions and 17 deletions
+1 -1
View File
@@ -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)
+5 -5
View File
@@ -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())
}
}
}