Feat: create upload session and pre-upload check

This commit is contained in:
HFO4
2022-02-10 19:30:08 +08:00
parent 855c9d92c4
commit de9c41082c
18 changed files with 82 additions and 135 deletions

View File

@@ -354,15 +354,15 @@ func FileUploadStream(c *gin.Context) {
})
}
// GetUploadCredential 获取上传凭证
// GetUploadCredential 创建上传会话
func GetUploadCredential(c *gin.Context) {
// 创建上下文
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
var service explorer.UploadCredentialService
if err := c.ShouldBindQuery(&service); err == nil {
res := service.Get(ctx, c)
var service explorer.UploadSessionService
if err := c.ShouldBindJSON(&service); err == nil {
res := service.Create(ctx, c)
c.JSON(200, res)
} else {
c.JSON(200, ErrorResponse(err))

View File

@@ -506,8 +506,8 @@ func InitMasterRouter() *gin.Engine {
{
// 文件上传
file.POST("upload", controllers.FileUploadStream)
// 获取上传凭证
file.GET("upload/credential", controllers.GetUploadCredential)
// 创建上传会话
file.PUT("upload/session", controllers.GetUploadCredential)
// 更新文件
file.PUT("update/:id", controllers.PutContent)
// 创建空白文件