Add: filesystem

This commit is contained in:
HFO4
2019-11-16 13:37:42 +08:00
parent d86a3533ca
commit 003274162b
6 changed files with 106 additions and 12 deletions

View File

@@ -3,6 +3,7 @@ package controllers
import (
"cloudreve/models"
"cloudreve/pkg/serializer"
"cloudreve/service/file"
"github.com/gin-gonic/gin"
)
@@ -15,18 +16,12 @@ func FileUpload(c *gin.Context) {
return
}
name := c.PostForm("name")
path := c.PostForm("path")
var service file.UploadService
// Source
_, err := c.FormFile("file")
if err != nil {
c.JSON(200, serializer.Err(serializer.CodeIOFailed, "无法获取文件数据", err))
return
if err := c.ShouldBind(&service); err == nil {
res := service.Upload(c)
c.JSON(200, res)
} else {
c.JSON(200, ErrorResponse(err))
}
c.JSON(200, serializer.Response{
Code: 0,
Msg: name + path,
})
}

View File

@@ -14,6 +14,7 @@ func ParamErrorMsg(filed string, tag string) string {
fieldMap := map[string]string{
"UserName": "邮箱",
"Password": "密码",
"Path": "路径",
}
// 未通过的规则与中文对应
tagMap := map[string]string{