diff options
Diffstat (limited to 'src/files.rs')
| -rw-r--r-- | src/files.rs | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/files.rs b/src/files.rs index bcda6ab..00d16b2 100644 --- a/src/files.rs +++ b/src/files.rs @@ -1,6 +1,10 @@ use crate::config::{SAVE_FILE_BASE_PATH, UPLOADS_ENDPOINT}; use crate::errors::AppError; -use axum::extract::Multipart; +use axum::{ + extract::{Multipart, Path}, + http::header::HeaderMap, +}; +use std::fs::read; use rand::random; @@ -45,3 +49,16 @@ pub async fn upload( "File extension not supported".to_string(), )) } + +/// Axum endpoint which shows uploaded file +pub async fn show_uploads(Path(id): Path<String>) -> (HeaderMap, Vec<u8>) { + // let index = id.find(".").map(|i| i).unwrap_or(usize::max_value()); + + // let mut ext_name = "xxx"; + // if index != usize::max_value() { + // ext_name = &id[index + 1..]; + // } + let headers = HeaderMap::new(); + let file_name = format!("{}/{}", SAVE_FILE_BASE_PATH, id); + (headers, read(&file_name).unwrap()) +} |
