ziwen 1 年之前
父节点
当前提交
97f7cbef11
共有 1 个文件被更改,包括 0 次插入58 次删除
  1. 0 58
      controllers/resource.go

+ 0 - 58
controllers/resource.go

@@ -1,58 +0,0 @@
-package controllers
-
-import (
-	"eta/eta_hub/models"
-	"os"
-)
-type ResourceController struct {
-	BaseAuthController
-}
-
-// ResourceUpload 上传文件
-// @Title 上传文件
-// @Description 上传文件
-// @Param   MenuId  query  int  true  "目录ID"
-// @Param   File	query  file  true  "文件"
-// @Success 200 Ret=200 操作成功
-// @router /resource/upload [post]
-func (this *ResourceController) ResourceUpload() {
-	br := new(models.BaseResponse).Init()
-	defer func() {
-		this.Data["json"] = br
-		this.ServeJSON()
-	}()
-
-	f, h, e := this.GetFile("file")
-	if e != nil {
-		br.Msg = "获取资源信息失败"
-		br.ErrMsg = "获取资源信息失败, Err:" + e.Error()
-		return
-	}
-	defer func() {
-		_ = f.Close()
-	}()
-
-
-	uploadDir :=  "./static/"
-	//uploadDir :=  "/Users/xi/Desktop/file"
-	if e = os.MkdirAll(uploadDir, 766); e != nil {
-		br.Msg = "存储目录创建失败"
-		br.ErrMsg = "存储目录创建失败, Err:" + e.Error()
-		return
-	}
-	//ossFileName := utils.GetRandStringNoSpecialChar(28) + ext
-	filePath := uploadDir + "/" + h.Filename
-	if e = this.SaveToFile("file", filePath); e != nil {
-		br.Msg = "文件保存失败"
-		br.ErrMsg = "文件保存失败, Err:" + e.Error()
-		return
-	}
-	//defer func() {
-	//	_ = os.Remove(filePath)
-	//}()
-
-
-	br.Msg = "上传成功"
-	br.Ret = 200
-	br.Success = true
-}