diff --git a/src/main.rs b/src/main.rs index 7aef76b..c5ba312 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,6 +10,7 @@ use actix_web::{ }; use actix_web_actors::ws; use log::error; +use serde::Deserialize; use store::FileStore; use tokio::sync::RwLock; @@ -17,20 +18,25 @@ const APP_NAME: &str = "transbeam"; type AppData = web::Data>; -#[get("/download/{file_code}")] +#[derive(Deserialize)] +struct DownloadRequest { + code: String, +} + +#[get("/download")] async fn handle_download( req: HttpRequest, - path: web::Path, + download: web::Query, data: AppData, ) -> actix_web::Result { - let file_code = path.into_inner(); - if !store::is_valid_storage_code(&file_code) { + let code = &download.code; + if !store::is_valid_storage_code(code) { return Ok(HttpResponse::NotFound().finish()); } let data = data.read().await; - let info = data.lookup_file(&file_code); + let info = data.lookup_file(code); if let Some(info) = info { - let storage_path = store::storage_dir().join(file_code); + let storage_path = store::storage_dir().join(code); let file = File::open(&storage_path)?; Ok(download::DownloadingFile { file, diff --git a/static/index.html b/static/index.html index d792bb1..f800d1c 100644 --- a/static/index.html +++ b/static/index.html @@ -16,9 +16,6 @@

transbeam

- - -
@@ -36,11 +33,11 @@
-