# fileops **Repository Path**: ligts/fileops ## Basic Information - **Project Name**: fileops - **Description**: 一个支持rustfs和minio存储的文件上传下载的示例 - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 1 - **Created**: 2025-09-25 - **Last Updated**: 2026-07-31 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 文件存储服务项目 这是一个完整的文件存储服务解决方案,包含以下组件: ## 项目结构 1. **主应用** (`file-service`): 基于Spring Boot的文件存储服务,支持MinIO和RustFS两种存储后端 2. **Starter模块** (`file-storage-starter`): 封装了文件存储功能的Spring Boot Starter,方便在其他项目中使用 3. **示例应用** (`file-storage-demo`): 演示如何使用Starter模块的示例项目 ## 主要功能 - 支持文件上传和下载 - 支持MinIO和RustFS两种存储后端 - 可通过配置切换存储后端 - 提供Docker Compose部署方案 ## 快速开始 ### 启动存储服务 使用Docker Compose启动MinIO和RustFS: ```bash docker-compose up -d ``` ### 运行主应用 ```bash mvn spring-boot:run ``` ### 使用Starter模块 1. 构建并安装Starter到本地Maven仓库: ```bash cd file-storage-starter mvn install ``` 2. 在其他项目中添加依赖: ```xml com.example file-storage-spring-boot-starter 1.0.0 ``` 3. 在`application.properties`中配置: ```properties # 存储类型配置 (minio 或 rustfs) file.storage.type=minio # MinIO配置 file.storage.minio.endpoint=http://localhost:9100 file.storage.minio.accessKey=minioadmin file.storage.minio.secretKey=minioadmin file.storage.minio.bucket-name=file-storage file.storage.minio.enabled=true # RustFS配置 (兼容S3 API) file.storage.rustfs.endpoint=http://localhost:9000 file.storage.rustfs.accessKey=rustfsadmin file.storage.rustfs.secretKey=rustfsadmin file.storage.rustfs.bucket-name=file-storage file.storage.rustfs.enabled=false ``` 4. 在代码中使用: ```java @Autowired private FileStorageService fileStorageService; // 上传文件 String fileName = fileStorageService.storeFile(file); // 下载文件 Resource resource = fileStorageService.loadFileAsResource(fileName); ``` ## API接口 - POST `/api/files/upload` - 上传文件 - GET `/api/files/download/{fileName}` - 下载文件 ## 配置说明 ### 存储后端切换 通过修改`storage.type`或`file.storage.type`配置项来切换存储后端: - `minio`: 使用MinIO存储 - `rustfs`: 使用RustFS存储 ## Docker部署 使用docker-compose.yml文件管理容器: ```bash # 启动服务 docker-compose up -d # 停止服务 docker-compose down # 查看服务状态 docker-compose ps ``` ## 许可证 MIT