Can upload files

This commit is contained in:
2025-04-09 21:12:47 +02:00
parent 84e1c57dc9
commit 61a4ea62c6
24 changed files with 342 additions and 61 deletions

@ -0,0 +1,18 @@
use crate::controllers::HttpResult;
use crate::extractors::auth_extractor::AuthExtractor;
use crate::extractors::file_extractor::FileExtractor;
use crate::services::files_service;
use actix_web::HttpResponse;
/// Upload a new file
pub async fn upload(auth: AuthExtractor, file: FileExtractor) -> HttpResult {
let file = files_service::create_file_with_mimetype(
auth.user_id(),
&file.name(),
&file.mime,
&file.buff,
)
.await?;
Ok(HttpResponse::Ok().json(file))
}

@ -4,6 +4,7 @@ use std::error::Error;
pub mod accounts_controller;
pub mod auth_controller;
pub mod files_controller;
pub mod server_controller;
pub mod static_controller;
pub mod tokens_controller;

@ -59,7 +59,7 @@ pub async fn create(auth: AuthExtractor, req: web::Json<CreateTokenBody>) -> Htt
right_account: req.right_account,
right_movement: req.right_movement,
right_inbox: req.right_inbox,
right_attachment: req.right_attachment,
right_file: req.right_attachment,
right_auth: req.right_auth,
})
.await?;