fix(upload): add account to upload record

This commit is contained in:
Derrick Hammer 2023-06-29 05:42:59 -04:00
parent 637b656d36
commit e018a4b743
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
2 changed files with 5 additions and 3 deletions

View File

@ -6,6 +6,7 @@ import (
"git.lumeweb.com/LumeWeb/portal/controller/response" "git.lumeweb.com/LumeWeb/portal/controller/response"
"git.lumeweb.com/LumeWeb/portal/logger" "git.lumeweb.com/LumeWeb/portal/logger"
"git.lumeweb.com/LumeWeb/portal/middleware" "git.lumeweb.com/LumeWeb/portal/middleware"
"git.lumeweb.com/LumeWeb/portal/service/auth"
"git.lumeweb.com/LumeWeb/portal/service/files" "git.lumeweb.com/LumeWeb/portal/service/files"
"github.com/kataras/iris/v12" "github.com/kataras/iris/v12"
"go.uber.org/zap" "go.uber.org/zap"
@ -33,7 +34,7 @@ func (f *FilesController) PostUpload() {
return return
} }
upload, err := files.Upload(file, meta.Size, nil) upload, err := files.Upload(file, meta.Size, nil, auth.GetCurrentUserId(ctx))
if internalError(ctx, err) { if internalError(ctx, err) {
logger.Get().Debug("failed uploading file", zap.Error(err)) logger.Get().Debug("failed uploading file", zap.Error(err))

View File

@ -54,7 +54,7 @@ func Init() {
client.SetDisableWarn(true) client.SetDisableWarn(true)
} }
func Upload(r io.ReadSeeker, size int64, hash []byte) (model.Upload, error) { func Upload(r io.ReadSeeker, size int64, hash []byte, accountID uint) (model.Upload, error) {
var upload model.Upload var upload model.Upload
tree, hashBytes, err := bao.ComputeTree(r, size) tree, hashBytes, err := bao.ComputeTree(r, size)
@ -146,7 +146,8 @@ func Upload(r io.ReadSeeker, size int64, hash []byte) (model.Upload, error) {
} }
upload = model.Upload{ upload = model.Upload{
Hash: hashHex, Hash: hashHex,
AccountID: accountID,
} }
if err = db.Get().Create(&upload).Error; err != nil { if err = db.Get().Create(&upload).Error; err != nil {