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

View File

@@ -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))
}