feat: 支持 targetDir 指定上传目标目录(网盘式),固定路径模式不变
- 改动:init/check 接受可选 targetDir(相对 CloudDir,SanitizeDir 校验),merge 物理落盘 CloudDir/<targetDir>/ - 秒传跨目录 copy-on-hit:库把旧物理文件复制进目标目录,OnInstantHit 携带新路径;源缺失回退正常上传 - 断点续传按目录隔离:同 MD5 在途任务目录不同则另起新任务 - TaskInfo 新增 TargetDir(宿主须持久化);Repository 12 方法接口零变更,向后兼容 v1.0.x - 新增 dir.go(SanitizeDir/路径拼装反解/copyFile)与 service_test.go(10 个用例:双模式秒传/续传隔离/merge 回归) - 原因:上传位置原本固定在 CloudDir 根,宿主无法实现网盘式选目录上传
This commit is contained in:
+4
-2
@@ -35,6 +35,7 @@ type TaskInfo struct {
|
||||
ChunkSize int64
|
||||
TotalChunk int32
|
||||
Status string // uploading / merging / done / error
|
||||
TargetDir string // 目标目录(相对 CloudDir,/ 分隔,空=根目录);宿主须持久化该字段
|
||||
StoragePath string // 相对路径(如 cloud/xxx),由宿主的目录约定决定
|
||||
Operator string
|
||||
TenantId int64
|
||||
@@ -70,8 +71,9 @@ type Options struct {
|
||||
// CloudDir 合并产物目录(宿主的云盘/文件目录约定)。
|
||||
CloudDir string
|
||||
// WebPathPrefix storagePath 的 Web 相对前缀(如 "cloud"),空则无前缀。
|
||||
// 最终 storagePath = WebPathPrefix + "/" + 产物名(存库、回调、BS 拼接均用该值),
|
||||
// 需与 CloudDir 相对宿主静态根的子目录一致。
|
||||
// 最终 storagePath = WebPathPrefix + "/" + [targetDir + "/"] + 产物名
|
||||
// (存库、回调、BS 拼接均用该值);targetDir 物理上是 CloudDir 下的真实子目录,
|
||||
// 前缀则只是 URL 拼接约定,需与 CloudDir 相对宿主静态根的子目录一致。
|
||||
WebPathPrefix string
|
||||
// URLPrefix 拼接 fileUrl 的静态前缀,默认 "/uploads";
|
||||
// 最终 fileUrl = URLPrefix + "/" + storagePath。
|
||||
|
||||
Reference in New Issue
Block a user