catface_backend_go/app/http/controller/web/upload_controller.go
2024-10-14 13:49:16 +08:00

26 lines
720 B
Go

package web
import (
"catface/app/global/consts"
"catface/app/global/variable"
"catface/app/service/upload_file"
"catface/app/utils/response"
"github.com/gin-gonic/gin"
)
type Upload struct {
}
// 文件上传是一个独立模块,给任何业务返回文件上传后的存储路径即可。
//
// 开始上传
func (u *Upload) StartUpload(context *gin.Context) {
savePath := variable.BasePath + variable.ConfigYml.GetString("FileUploadSetting.UploadFileSavePath")
if r, finnalSavePath := upload_file.Upload(context, savePath); r == true {
response.Success(context, consts.CurdStatusOkMsg, finnalSavePath)
} else {
response.Fail(context, consts.FilesUploadFailCode, consts.FilesUploadFailMsg, "")
}
}