This project is a Java Spring Boot application that integrates MinIO, an open-source object storage service. The application provides functionalities for managing file uploads, storage, and retrieval, using MinIO as a storage backend.
- File Upload: Allows users to upload files to the MinIO server.
- File Download: Enables downloading of stored files.
- File Metadata Management: Keeps track of file metadata through a database.
- Error Handling: Custom exceptions are used to provide meaningful error messages.
- Java 17: Core programming language.
- Spring Boot: Framework for building the RESTful API.
- MinIO: Object storage system used for storing uploaded files.
- Maven: Dependency management.
- H2 Database: Embedded database for storing file metadata (can be replaced with other databases).
config
: Contains configuration classes including MinIO connection properties.controller
: Handles incoming HTTP requests related to file operations.domain
: Represents entities, such asFileEntity
, used to store file-related data.repo
: Manages database operations for storing and retrieving file metadata.service
: Contains services for interacting with MinIO and managing files.utils
: Utility classes for file operations.
- Java 17 or higher
- Maven for building the project
- MinIO Server running locally or accessible remotely
-
Clone the repository
git clone <repository-url> cd minio-file-service
-
Set up MinIO configuration
- Update the
.env
file orapplication.properties
with your MinIO credentials (e.g., access key, secret key, and endpoint).
- Update the
-
Build the project
./mvnw clean install
-
Run the application
./mvnw spring-boot:run
- Upload a File: Use an API client like Postman to send a
POST
request to/api/files/upload
with the file in the request body. - Download a File: Send a
GET
request to/api/files/download/{fileId}
to retrieve a file.
- The application properties for connecting to MinIO are defined in the
application.properties
file. - You can modify the following settings:
minio.url
: The URL of the MinIO server.minio.access-key
: Your MinIO access key.minio.secret-key
: Your MinIO secret key.
The application uses custom exceptions to handle errors, such as FileException
and InvalidRequestException
. These exceptions ensure meaningful messages are returned to users.
This project is licensed under the MIT License. See the LICENSE
file for details.
Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.
For any issues or inquiries, please contact:
- Developer Name: Javohir Yallayev
- Email: [email protected]
- GitHub: javohirdeveloper0612