mirror of
https://github.com/halejohn/Cloudreve.git
synced 2026-01-26 09:34:57 +08:00
Feat: create upload session and pre-upload check
This commit is contained in:
@@ -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))
|
||||
|
||||
@@ -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)
|
||||
// 创建空白文件
|
||||
|
||||
Reference in New Issue
Block a user