Repository navigation
Expand file tree
/
Copy pathfile.api
More file actions
289 lines (233 loc) · 7.25 KB
/
Copy pathfile.api
File metadata and controls
289 lines (233 loc) · 7.25 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
syntax = "v1"
info (
title: "CloudDrive File API"
desc: "File and folder management HTTP API"
author: "CloudDrive"
version: "v1"
)
// 说明:两个流式接口(文件下载、分享下载)需要直接写 ResponseWriter,
// goctl 的 JSON 绑定不适用,因此手写在 internal/handler/download.go,
// 由 internal/handler/routes.go 手工注册。
type FileItem {
FileID int64 `json:"fileId"`
ParentID int64 `json:"parentId"`
Name string `json:"name"`
Size int64 `json:"size"`
ContentType string `json:"contentType"`
IsFolder bool `json:"isFolder"`
Status string `json:"status"`
Version int64 `json:"version"`
CreatedAt int64 `json:"createdAt"`
UpdatedAt int64 `json:"updatedAt"`
}
type ListFilesReq {
ParentID int64 `form:"parentId,optional"`
Page int64 `form:"page,default=1"`
PageSize int64 `form:"pageSize,default=20"`
}
type ListFilesResp {
Items []FileItem `json:"items"`
Total int64 `json:"total"`
Page int64 `json:"page"`
PageSize int64 `json:"pageSize"`
}
type CreateFolderReq {
ParentID int64 `json:"parentId"`
Name string `json:"name"`
}
type CreateFolderResp {
FolderID int64 `json:"folderId"`
}
type FileIDReq {
FileID int64 `path:"fileId"`
}
type FolderIDReq {
FolderID int64 `path:"folderId"`
}
type RenameFileReq {
FileID int64 `path:"fileId"`
Name string `json:"name"`
}
type MoveFileReq {
FileID int64 `path:"fileId"`
TargetParentID int64 `json:"targetParentId"`
Name string `json:"name,optional"`
}
type DeleteFileResp {
Success bool `json:"success"`
ReleasedBytes int64 `json:"releasedBytes"`
}
type GetFileResp {
File FileItem `json:"file"`
}
type InitUploadReq {
ParentID int64 `json:"parentId"`
Name string `json:"name"`
Size int64 `json:"size"`
ContentType string `json:"contentType,optional"`
ContentHash string `json:"contentHash,optional"`
IdempotencyKey string `json:"idempotencyKey,optional"`
}
type InitUploadResp {
UploadID string `json:"uploadId"`
FileID int64 `json:"fileId"`
ChunkSize int64 `json:"chunkSize"`
TotalChunks int64 `json:"totalChunks"`
ExpiresAt int64 `json:"expiresAt"`
}
type UploadProgressReq {
UploadID string `path:"uploadId"`
}
type UploadPartState {
PartNumber int64 `json:"partNumber"`
Size int64 `json:"size"`
ETag string `json:"etag"`
}
type UploadProgressResp {
UploadID string `json:"uploadId"`
Status string `json:"status"`
FileID int64 `json:"fileId"`
FileName string `json:"fileName"`
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 CompleteUploadReq {
UploadID string `path:"uploadId"`
}
type CompleteUploadResp {
FileID int64 `json:"fileId"`
Version int64 `json:"version"`
Status string `json:"status"`
}
type AbortUploadReq {
UploadID string `path:"uploadId"`
}
type AbortUploadResp {
Success bool `json:"success"`
}
type InitVersionUploadReq {
FileID int64 `path:"fileId"`
Size int64 `json:"size"`
ContentType string `json:"contentType,optional"`
ContentHash string `json:"contentHash,optional"`
}
type ListVersionsReq {
FileID int64 `path:"fileId"`
}
type VersionItem {
Version int64 `json:"version"`
Size int64 `json:"size"`
ContentType string `json:"contentType"`
ContentHash string `json:"contentHash"`
Current bool `json:"current"`
CreatedAt int64 `json:"createdAt"`
}
type ListVersionsResp {
Items []VersionItem `json:"items"`
}
type RestoreVersionReq {
FileID int64 `path:"fileId"`
Version int64 `path:"version"`
}
type RestoreVersionResp {
Success bool `json:"success"`
Version int64 `json:"version"`
}
type CreateShareReq {
FileID int64 `json:"fileId"`
Password string `json:"password,optional"`
ExpiresAt int64 `json:"expiresAt,optional"`
MaxAccessCount int64 `json:"maxAccessCount,optional"`
}
type CreateShareResp {
ShareID int64 `json:"shareId"`
Token string `json:"token"`
URL string `json:"url"`
ExpiresAt int64 `json:"expiresAt"`
}
type ShareItem {
ShareID int64 `json:"shareId"`
FileID int64 `json:"fileId"`
FileName string `json:"fileName"`
Active bool `json:"active"`
HasPassword bool `json:"hasPassword"`
ExpiresAt int64 `json:"expiresAt"`
MaxAccessCount int64 `json:"maxAccessCount"`
AccessCount int64 `json:"accessCount"`
CreatedAt int64 `json:"createdAt"`
}
type ListSharesReq {
Page int64 `form:"page,default=1"`
PageSize int64 `form:"pageSize,default=20"`
}
type ListSharesResp {
Items []ShareItem `json:"items"`
Total int64 `json:"total"`
Page int64 `json:"page"`
PageSize int64 `json:"pageSize"`
}
type ShareIDReq {
ShareID int64 `path:"shareId"`
}
type RevokeShareResp {
Success bool `json:"success"`
}
type AccessShareReq {
Token string `path:"token"`
Password string `json:"password,optional"`
}
type AccessShareResp {
Granted bool `json:"granted"`
FileName string `json:"fileName"`
Size int64 `json:"size"`
ContentType string `json:"contentType"`
DownloadURL string `json:"downloadUrl"`
}
type DownloadSharedFileReq {
Token string `path:"token"`
Password string `form:"password,optional"`
}
service file-api {
@handler ListFiles
get /v1/files (ListFilesReq) returns (ListFilesResp)
@handler GetFile
get /v1/files/:fileId (FileIDReq) returns (GetFileResp)
@handler CreateFolder
post /v1/folders (CreateFolderReq) returns (CreateFolderResp)
@handler DeleteFolder
delete /v1/folders/:folderId (FolderIDReq) returns (DeleteFileResp)
@handler RenameFile
put /v1/files/:fileId/name (RenameFileReq)
@handler MoveFile
put /v1/files/:fileId/parent (MoveFileReq)
@handler DeleteFile
delete /v1/files/:fileId (FileIDReq) returns (DeleteFileResp)
@handler InitUpload
post /v1/uploads (InitUploadReq) returns (InitUploadResp)
@handler GetUploadProgress
get /v1/uploads/:uploadId (UploadProgressReq) returns (UploadProgressResp)
@handler CompleteUpload
post /v1/uploads/:uploadId/complete (CompleteUploadReq) returns (CompleteUploadResp)
@handler AbortUpload
delete /v1/uploads/:uploadId (AbortUploadReq) returns (AbortUploadResp)
@handler InitVersionUpload
post /v1/files/:fileId/versions (InitVersionUploadReq) returns (InitUploadResp)
@handler ListVersions
get /v1/files/:fileId/versions (ListVersionsReq) returns (ListVersionsResp)
@handler RestoreVersion
post /v1/files/:fileId/versions/:version/restore (RestoreVersionReq) returns (RestoreVersionResp)
@handler CreateShare
post /v1/shares (CreateShareReq) returns (CreateShareResp)
@handler ListShares
get /v1/shares (ListSharesReq) returns (ListSharesResp)
@handler RevokeShare
delete /v1/shares/:shareId (ShareIDReq) returns (RevokeShareResp)
@handler AccessShare
post /v1/shares/:token/access (AccessShareReq) returns (AccessShareResp)
}