# ofs **Repository Path**: gzcltech/ofs ## Basic Information - **Project Name**: ofs - **Description**: 对象文件存储,参考x-file-storage实现 - **Primary Language**: Java - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-07-26 - **Last Updated**: 2026-09-05 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # OFS 对象文件存储(Object File Storage),参考 [x-file-storage](https://github.com/dromara/x-file-storage) 实现,提供统一的文件上传、下载、复制、移动、分片上传、预签名 URL 等能力。 ## 技术栈 - Java 25 - Spring Boot 4.0 - 不包含 Solon 模块(已移除 `x-file-storage-solon`) ## 模块说明 | 模块 | 说明 | |------|------| | `ofs-core` | 核心库,支持本地、FTP、SFTP、WebDAV 及各类云存储平台 | | `ofs-spring` | Spring Boot 集成,提供 `@EnableFileStorage` 自动配置 | | `ofs-oss-sts` | 阿里云 OSS STS 核心扩展 | | `ofs-oss-sts-spring` | 阿里云 OSS STS Spring Boot 集成,配置项 `aliyun-oss-sts` | | `example-ofs-oss` | 阿里云 OSS 使用示例 | | `example-ofs-custom` | `FileStorageServiceBuilderCustomizer` 自定义扩展示例 | ## 快速开始 ### Maven 依赖 ```xml io.gitee.gzcltech.ofs ofs-spring 4.0.0 ``` ### 启用 ```java @SpringBootApplication @EnableFileStorage public class Application { public static void main(String[] args) { SpringApplication.run(Application.class, args); } } ``` ### 配置示例 ```yaml ofs: default-platform: local-plus-1 local-plus: - platform: local-plus-1 enable-storage: true enable-access: true domain: http://127.0.0.1:8080/ base-path: /files/ path-patterns: /files/** storage-path: /tmp/files/ ``` > 配置前缀由 x-file-storage 的 `dromara.x-file-storage` 调整为 `ofs`。 ### 上传示例 ```java @Autowired private FileStorageService fileStorageService; public FileInfo upload(MultipartFile file) { return fileStorageService.of(file).upload(); } ``` ## 示例模块 阿里云 OSS 示例见 [`example-ofs-oss`](example-ofs-oss/README.md): ```bash export ALIYUN_OSS_ACCESS_KEY=your-access-key export ALIYUN_OSS_SECRET_KEY=your-secret-key export ALIYUN_OSS_ENDPOINT=oss-cn-hangzhou.aliyuncs.com export ALIYUN_OSS_BUCKET=your-bucket export ALIYUN_OSS_DOMAIN=https://your-bucket.oss-cn-hangzhou.aliyuncs.com/ ./mvnw -pl example-ofs-oss -am spring-boot:run ``` Customizer 自定义扩展示例见 [`example-ofs-custom`](example-ofs-custom/README.md): ```bash ./mvnw -pl example-ofs-custom -am spring-boot:run # GET http://127.0.0.1:8081/platforms ``` ## 构建 ```bash ./mvnw clean compile -DskipTests -Dspotless.check.skip=true ``` ## 许可证 Apache License 2.0