DFS API
The API defines DfsTemplate and immutable file models. The selected binder registers a DfsTemplate bean.
Business code should use only DfsTemplate and io.github.loadup.components.dfs.model types. The API covers object
CRUD, metadata, presigned download URLs, and the multipart upload lifecycle. Multipart and presigned operations are
optional binder capabilities and report UnsupportedOperationException when unavailable.
接入步骤
在引入 loadup-framework-bom BOM 的应用中添加:
<dependency><groupId>io.github.loadup-cloud</groupId><artifactId>loadup-components-dfs-api</artifactId></dependency>通过 loadup.dfs.binder-type 选择 local、s3 或 database;业务层注入 DfsTemplate。
运行时还需在应用侧引入一种对应 binder;仅有接口 jar 不会创建实际后端能力。
对外契约
业务代码注入 DfsTemplate 后,可调用 upload(FileUploadRequest)、download(fileId)、
getMetadata(fileId) 和 delete(fileId)。需要临时下载链接或分片上传时,先确认所选 binder
支持对应能力;当前能力差异见父模块 README。
自动装配
各 binder 按 loadup.dfs.binder-type 匹配并注册 DfsTemplate。应用可自行提供一个 DfsTemplate Bean。
设计与装配路径见 ARCHITECTURE.md。
设计与实现
DfsTemplate 是业务调用与 binder 实现共用的接口。基础契约包含上传、下载、删除、存在性查询和元数据读取。预签名和分片上传由支持该能力的 binder 实现,默认抛出 UnsupportedOperationException。
装配规则
新增 binder 在自己的 AutoConfiguration.imports 注册配置,以 loadup.dfs.binder-type 匹配自己的标识,并在应用尚未提供 DfsTemplate 时创建一个 Bean。binder auto-configuration 声明 before = DfsAutoConfiguration.class。
DfsAutoConfiguration 提供公共排序点。File 等可选消费者在此之后判断 DfsTemplate 是否存在。业务模块和 API 均可以通过 DfsTemplate 接入新增 binder。
集成方式见 README.md。