Repository navigation
Expand file tree
/
Copy pathstorage.api
More file actions
56 lines (47 loc) · 1.78 KB
/
Copy pathstorage.api
File metadata and controls
56 lines (47 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
syntax = "v1"
info (
title: "CloudDrive Storage API"
desc: "Storage data plane: chunk upload, upload progress, object download"
author: "CloudDrive"
version: "v1"
)
// 数据面的两个流式接口(分片上传、对象下载)需要直接操作 http.ResponseWriter
// 和请求体,goctl 的 JSON 绑定不适合,因此在 internal/handler/dataplane.go 手写,
// 由 handler/routes.go 手工注册。其余 JSON 接口走 goctl 生成。
type UploadProgressReq {
UploadID string `path:"uploadId"`
}
type UploadPartState {
PartNumber int64 `json:"partNumber"`
Size int64 `json:"size"`
ETag string `json:"etag"`
ContentHash string `json:"contentHash"`
}
type UploadProgressResp {
UploadID string `json:"uploadId"`
Status string `json:"status"`
FileName string `json:"fileName"`
ContentType string `json:"contentType"`
TotalSize int64 `json:"totalSize"`
ChunkSize int64 `json:"chunkSize"`
TotalChunks int64 `json:"totalChunks"`
UploadedChunks int64 `json:"uploadedChunks"`
UploadedBytes int64 `json:"uploadedBytes"`
MissingParts []int64 `json:"missingParts"`
Parts []UploadPartState `json:"parts"`
ExpiresAt int64 `json:"expiresAt"`
}
type AbortUploadReq {
UploadID string `path:"uploadId"`
}
type AbortUploadResp {
Success bool `json:"success"`
}
service storage-api {
// 查询上传进度(断点续传:客户端据此补传 missingParts)。
@handler GetUploadProgress
get /v1/uploads/:uploadId (UploadProgressReq) returns (UploadProgressResp)
// 取消上传任务。
@handler AbortUpload
delete /v1/uploads/:uploadId (AbortUploadReq) returns (AbortUploadResp)
}