Display info of uploaded files

This commit is contained in:
2025-04-28 21:38:27 +02:00
parent 3ae229a275
commit c6851bb50d
7 changed files with 78 additions and 3 deletions

View File

@ -39,6 +39,11 @@ pub async fn upload(auth: AuthExtractor, file: FileExtractor) -> HttpResult {
Ok(HttpResponse::Ok().json(file))
}
/// Get information about a file
pub async fn get_info(file_extractor: FileIdExtractor) -> HttpResult {
Ok(HttpResponse::Ok().json(file_extractor.as_ref()))
}
/// Download an uploaded file
pub async fn download(req: HttpRequest, file_extractor: FileIdExtractor) -> HttpResult {
serve_file(req, file_extractor.as_ref()).await

View File

@ -123,6 +123,10 @@ async fn main() -> std::io::Result<()> {
.route("/api/file", web::post().to(files_controller::upload))
.route(
"/api/file/{file_id}",
web::get().to(files_controller::get_info),
)
.route(
"/api/file/{file_id}/download",
web::get().to(files_controller::download),
)
.route(