✨ rename and mkdir api
This commit is contained in:
34
server/controllers/file/mkdir.go
Normal file
34
server/controllers/file/mkdir.go
Normal file
@ -0,0 +1,34 @@
|
||||
package file
|
||||
|
||||
import (
|
||||
"github.com/Xhofe/alist/drivers/operate"
|
||||
"github.com/Xhofe/alist/server/common"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type MkdirReq struct {
|
||||
Path string `json:"path"`
|
||||
}
|
||||
|
||||
func Mkdir(c *gin.Context) {
|
||||
var req MkdirReq
|
||||
if err := c.ShouldBind(&req); err != nil {
|
||||
common.ErrorResp(c, err, 400)
|
||||
return
|
||||
}
|
||||
account, path_, driver, err := common.ParsePath(req.Path)
|
||||
if err != nil {
|
||||
common.ErrorResp(c, err, 500)
|
||||
return
|
||||
}
|
||||
if path_ == "/" {
|
||||
common.ErrorStrResp(c, "Folder name can't be empty", 400)
|
||||
return
|
||||
}
|
||||
err = operate.MakeDir(driver, account, path_, true)
|
||||
if err != nil {
|
||||
common.ErrorResp(c, err, 500)
|
||||
return
|
||||
}
|
||||
common.SuccessResp(c)
|
||||
}
|
Reference in New Issue
Block a user