Display info of uploaded files
This commit is contained in:
@ -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
|
||||
|
@ -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(
|
||||
|
Reference in New Issue
Block a user