Can upload files
This commit is contained in:
18
moneymgr_backend/src/controllers/files_controller.rs
Normal file
18
moneymgr_backend/src/controllers/files_controller.rs
Normal 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))
|
||||
}
|
@ -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?;
|
||||
|
Reference in New Issue
Block a user