mirror of
https://github.com/cloudreve/Cloudreve.git
synced 2026-11-04 00:33:07 +00:00
Remove: mutipart file upload
This commit is contained in:
1 parent
7cb27b2102
commit
9d8a462dc4
8 files changed
+211
-93
No files matched your search
@@ -7,34 +7,10 @@ import (
|
||||
"github.com/HFO4/cloudreve/pkg/filesystem/local"
|
||||
"github.com/HFO4/cloudreve/pkg/serializer"
|
||||
"github.com/HFO4/cloudreve/pkg/util"
|
||||
"github.com/HFO4/cloudreve/service/file"
|
||||
"github.com/gin-gonic/gin"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// FileUpload 本地策略文件上传
|
||||
func FileUpload(c *gin.Context) {
|
||||
|
||||
// 非本地策略时拒绝上传
|
||||
if user, ok := c.Get("user"); ok && user.(*model.User).Policy.Type != "local" {
|
||||
c.JSON(200, serializer.Err(serializer.CodePolicyNotAllowed, "当前上传策略无法使用", nil))
|
||||
return
|
||||
}
|
||||
|
||||
// 建立上下文
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
|
||||
var service file.UploadService
|
||||
defer cancel()
|
||||
|
||||
if err := c.ShouldBind(&service); err == nil {
|
||||
res := service.Upload(ctx, c)
|
||||
c.JSON(200, res)
|
||||
} else {
|
||||
c.JSON(200, ErrorResponse(err))
|
||||
}
|
||||
}
|
||||
|
||||
// FileUploadStream 本地策略流式上传
|
||||
func FileUploadStream(c *gin.Context) {
|
||||
// 创建上下文
|
||||
|
||||
+2
-4
@@ -49,10 +49,8 @@ func InitRouter() *gin.Engine {
|
||||
// 文件
|
||||
file := auth.Group("File")
|
||||
{
|
||||
// 小文件上传
|
||||
file.POST("Upload", controllers.FileUpload)
|
||||
// 小文件上传
|
||||
file.POST("UploadStream", controllers.FileUploadStream)
|
||||
// 文件上传
|
||||
file.POST("Upload", controllers.FileUploadStream)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user