-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Files): Preview videos files in Storage and Chats (#1699)
- Loading branch information
Showing
28 changed files
with
699 additions
and
445 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
use std::{fs, io}; | ||
use warp::logging::tracing::log; | ||
|
||
use crate::STATIC_ARGS; | ||
|
||
pub fn clear_temp_files_directory() -> io::Result<()> { | ||
let temp_files_dir = fs::read_dir(STATIC_ARGS.temp_files.clone())?; | ||
for entry in temp_files_dir { | ||
let entry = entry?; | ||
let path = entry.path(); | ||
if path.is_dir() { | ||
fs::remove_dir_all(&path)?; | ||
} else { | ||
fs::remove_file(&path)?; | ||
} | ||
} | ||
log::debug!("Temporary files directory cleared"); | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
pub const IMAGE_MAX_WIDTH: &str = "80vw"; | ||
|
||
pub const IMAGE_MAX_HEIGHT: &str = "80vh"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
use std::path::PathBuf; | ||
|
||
/// It will work to load local files in img or video tags, but will ignore drive | ||
const PREFIX_TO_WORK_ON_WINDOWS_OS: &str = "http://dioxus."; | ||
|
||
/// This function is used to treat local file path if it needs | ||
/// to be loaded in img or video tags for example | ||
pub fn get_fixed_path_to_load_local_file(path: PathBuf) -> String { | ||
if !cfg!(target_os = "windows") { | ||
path.to_string_lossy().to_string() | ||
} else { | ||
format!( | ||
"{}{}", | ||
PREFIX_TO_WORK_ON_WINDOWS_OS, | ||
path.to_string_lossy().to_string().replace('\\', "/") | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
pub mod clear_temp_files_dir; | ||
pub mod img_dimensions_preview; | ||
pub mod lifecycle; | ||
pub mod local_file_path; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.