fix: 修复文件上传bug

This commit is contained in:
tangtanglove
2023-03-31 15:38:56 +08:00
parent 0be0df71ba
commit c2297cdf30
3 changed files with 17 additions and 31 deletions

View File

@@ -88,22 +88,15 @@ func (p *File) AfterHandle(ctx *builder.Context, result *storage.FileInfo) inter
result.Url = (&model.File{}).GetPath(result.Url) result.Url = (&model.File{}).GetPath(result.Url)
} }
adminInfo, err := (&model.Admin{}).GetAuthUser(ctx.Engine.GetConfig().AppKey, ctx.Token())
if err != nil {
return ctx.JSON(200, msg.Error(err.Error(), ""))
}
// 插入数据库 // 插入数据库
id, err := (&model.File{}).InsertGetId(&model.File{ id, err := (&model.File{}).InsertGetId(&model.File{
ObjType: "ADMINID", Name: result.Name,
ObjId: adminInfo.Id, Size: result.Size,
Name: result.Name, Ext: result.Ext,
Size: result.Size, Path: result.Path,
Ext: result.Ext, Url: result.Url,
Path: result.Path, Hash: result.Hash,
Url: result.Url, Status: 1,
Hash: result.Hash,
Status: 1,
}) })
if err != nil { if err != nil {
return ctx.JSON(200, msg.Error(err.Error(), "")) return ctx.JSON(200, msg.Error(err.Error(), ""))

View File

@@ -78,24 +78,17 @@ func (p *Image) AfterHandle(ctx *builder.Context, result *storage.FileInfo) inte
result.Url = (&model.Picture{}).GetPath(result.Url) result.Url = (&model.Picture{}).GetPath(result.Url)
} }
adminInfo, err := (&model.Admin{}).GetAuthUser(ctx.Engine.GetConfig().AppKey, ctx.Token())
if err != nil {
return msg.Error(err.Error(), "")
}
// 插入数据库 // 插入数据库
id, err := (&model.Picture{}).InsertGetId(&model.Picture{ id, err := (&model.Picture{}).InsertGetId(&model.Picture{
ObjType: "ADMINID", Name: result.Name,
ObjId: adminInfo.Id, Size: result.Size,
Name: result.Name, Width: result.Width,
Size: result.Size, Height: result.Height,
Width: result.Width, Ext: result.Ext,
Height: result.Height, Path: result.Path,
Ext: result.Ext, Url: result.Url,
Path: result.Path, Hash: result.Hash,
Url: result.Url, Status: 1,
Hash: result.Hash,
Status: 1,
}) })
if err != nil { if err != nil {

View File

@@ -19,7 +19,7 @@ const (
AppName = "QuarkGo" AppName = "QuarkGo"
// Version of current package // Version of current package
Version = "1.1.46" Version = "1.1.47"
// 静态文件URL // 静态文件URL
RespositoryURL = "https://github.com/quarkcms/quark-go/tree/main/website/" RespositoryURL = "https://github.com/quarkcms/quark-go/tree/main/website/"