feat: Implement file upload functionality with MinIO integration
- Added new dependencies for HMAC, hex, and urlencoding in Cargo.toml. - Introduced FileUploadSchema for handling multipart file uploads. - Enhanced UsersService with upload_file method to handle file uploads to MinIO. - Implemented MinioService for managing MinIO interactions, including file uploads and presigned URL generation. - Updated environment configuration to include MinIO region and secure settings. - Added validation for file types and sizes during upload. - Improved error handling and logging for file upload processes. - Created utility functions for base64 decoding and content type extraction.
This commit is contained in:
@@ -7,12 +7,22 @@ use axum::extract::{Path, Multipart};
|
||||
use axum::http::HeaderMap;
|
||||
use axum::response::IntoResponse;
|
||||
use axum::{Extension, Json};
|
||||
use utoipa::ToSchema;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use super::{
|
||||
UsersActiveInactiveRequestDto, UsersListItemDto, UsersUpdateRequestDto,
|
||||
};
|
||||
use crate::v1::users::users_service::{UsersServiceTrait, UsersService};
|
||||
|
||||
#[derive(Serialize, Deserialize, ToSchema)]
|
||||
#[schema(description = "File upload form data for multipart/form-data")]
|
||||
pub struct FileUploadSchema {
|
||||
/// Binary file data to upload
|
||||
#[schema(format = "binary")]
|
||||
pub file: String,
|
||||
}
|
||||
|
||||
#[utoipa::path(
|
||||
get,
|
||||
security(
|
||||
@@ -254,7 +264,11 @@ pub async fn delete_user(
|
||||
("Bearer" = [])
|
||||
),
|
||||
path = "/v1/users/upload",
|
||||
request_body(content = String, description = "Upload file", content_type = "multipart/form-data"),
|
||||
request_body(
|
||||
content = FileUploadSchema,
|
||||
description = "Upload file with multipart form data. Only 'file' field is required - file type will be detected automatically from the uploaded file.",
|
||||
content_type = "multipart/form-data"
|
||||
),
|
||||
responses(
|
||||
(status = 200, description = "Upload file successfully", body = ResponseSuccessDto<serde_json::Value>),
|
||||
(status = 400, description = "Bad request"),
|
||||
|
||||
Reference in New Issue
Block a user