Feat: slave policy creating upload session API

This commit is contained in:
HFO4
2022-02-27 14:22:09 +08:00
parent 7dd636da74
commit 2811ee3285
21 changed files with 236 additions and 106 deletions

View File

@@ -343,8 +343,8 @@ func FileUpload(c *gin.Context) {
//})
}
// DeleteUploadCredential 删除上传会话
func DeleteUploadCredential(c *gin.Context) {
// DeleteUploadSession 删除上传会话
func DeleteUploadSession(c *gin.Context) {
// 创建上下文
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
@@ -358,8 +358,8 @@ func DeleteUploadCredential(c *gin.Context) {
}
}
// DeleteAllCredential 删除全部上传会话
func DeleteAllCredential(c *gin.Context) {
// DeleteAllUploadSession 删除全部上传会话
func DeleteAllUploadSession(c *gin.Context) {
// 创建上下文
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
@@ -368,8 +368,8 @@ func DeleteAllCredential(c *gin.Context) {
c.JSON(200, res)
}
// GetUploadCredential 创建上传会话
func GetUploadCredential(c *gin.Context) {
// GetUploadSession 创建上传会话
func GetUploadSession(c *gin.Context) {
// 创建上下文
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

View File

@@ -90,6 +90,21 @@ func SlaveUpload(c *gin.Context) {
})
}
// SlaveGetUploadSession 从机创建上传会话
func SlaveGetUploadSession(c *gin.Context) {
// 创建上下文
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
var service explorer.SlaveCreateUploadSessionService
if err := c.ShouldBindJSON(&service); err == nil {
res := service.Create(ctx, c)
c.JSON(200, res)
} else {
c.JSON(200, ErrorResponse(err))
}
}
// SlaveDownload 从机文件下载,此请求返回的HTTP状态码不全为200
func SlaveDownload(c *gin.Context) {
// 创建上下文

View File

@@ -47,6 +47,8 @@ func InitSlaveRouter() *gin.Engine {
v3.POST("heartbeat", controllers.SlaveHeartbeat)
// 上传
v3.POST("upload", controllers.SlaveUpload)
// 创建上传会话上传
v3.PUT("upload", controllers.SlaveGetUploadSession)
// 下载
v3.GET("download/:speed/:path/:name", controllers.SlaveDownload)
// 预览 / 外链
@@ -510,11 +512,11 @@ func InitMasterRouter() *gin.Engine {
// 文件上传
upload.POST(":sessionId/:index", controllers.FileUpload)
// 创建上传会话
upload.PUT("", controllers.GetUploadCredential)
upload.PUT("", controllers.GetUploadSession)
// 删除给定上传会话
upload.DELETE(":sessionId", controllers.DeleteUploadCredential)
upload.DELETE(":sessionId", controllers.DeleteUploadSession)
// 删除全部上传会话
upload.DELETE("", controllers.DeleteAllCredential)
upload.DELETE("", controllers.DeleteAllUploadSession)
}
// 更新文件
file.PUT("update/:id", controllers.PutContent)