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))
|
||||
}
|
Reference in New Issue
Block a user