LoadUp DFS
Business code injects DfsTemplate. Each binder registers its own implementation.
Maven
Import the LoadUp BOM, then add loadup-components-dfs-api and exactly one binder:
<dependency>
<groupId>io.github.loadup-cloud</groupId>
<artifactId>loadup-components-dfs-api</artifactId>
</dependency>
<dependency>
<groupId>io.github.loadup-cloud</groupId>
<artifactId>loadup-components-dfs-binder-s3</artifactId>
</dependency>Configuration
Select a binder by its identifier in loadup.dfs.binder-type. The built-in binders use local, s3, and database.
Each additional binder supplies its own identifier. Binder-specific settings live under loadup.dfs.binder.<type>.
loadup:
dfs:
binder-type: s3
binder.s3.bucket: loadup-files
binder.s3.region: us-east-1Capabilities
| Capability | local | s3 | database |
|---|---|---|---|
| Upload, download, delete, exists, metadata | ✓ | ✓ | ✓ |
| Metadata survives process restart | ✓ | ✓ | ✓ |
| Presigned download URL | ✗ | ✓ | ✗ |
| Multipart upload | ✗ | ✓ | ✗ |
S3 is the recommended production binder. Local is for development and single-node deployments; database is a transitional small-file binder.
设计与实现
Each binder directly implements and registers DfsTemplate.
Business code → DfsTemplate implementation → storage systemEach binder declares its own loadup.dfs.binder-type value. Optional consumers such as File evaluate their bean conditions after
DfsAutoConfiguration. Each binder orders its auto-configuration before that shared point.
The S3 binder uses AWS SDK S3Client and S3Presigner, persists user metadata as object metadata, supports presigned
GET URLs, and exposes the S3 multipart lifecycle. It accepts AWS S3, MinIO, OSS, COS, and LocalStack through endpoint
and path-style settings.
The local binder stores objects and sidecar metadata below the configured root. The database binder stores small objects
and JSON metadata in dfs_file, using Spring JDBC and explicit audit fields. Database storage is retained as a
transitional implementation and is not the production default.
Download responses implement AutoCloseable; callers must close them after consuming the stream. Binders own their
clients and never expose SDK types through the facade.
分层与调用路径
预签名与分片操作取决于所选 binder 的能力。
loadup-components-dfs
└─ loadup-components-dfs-api
└─ loadup-components-dfs-binder-database
└─ loadup-components-dfs-binder-local
└─ loadup-components-dfs-binder-s3聚合 POM 组织模块与版本,运行时依赖由子模块决定。
各 binder 在自己的 src/test 中验证存储行为;本地 binder 也覆盖 DFS 服务契约。
数据库和 S3 集成测试分别通过 Testcontainers 启动 PostgreSQL 和 LocalStack。
设计取舍
聚合层只表达模块组合和依赖方向,实际能力由选定的子模块提供。
集成方式与配置示例见 README.md。