refactor: use CreateUpload

This commit is contained in:
Derrick Hammer 2024-01-17 14:49:35 -05:00
parent 5fec2f08ff
commit c338a41efd
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 2 additions and 9 deletions

View File

@ -177,17 +177,10 @@ func (h *HttpHandler) SmallFileUpload(jc jape.Context) {
return return
} }
tx := h.portal.Database().Create(&models.Upload{ _, err = h.portal.Storage().CreateUpload(hash, uint(jc.Request.Context().Value(AuthUserIDKey).(uint64)), jc.Request.RemoteAddr, uint64(bufferSize), "s5")
Hash: hex.EncodeToString(hash), if err != nil {
Size: uint64(bufferSize),
Protocol: "s5",
UserID: uint(jc.Request.Context().Value(AuthUserIDKey).(uint64)),
})
if tx.Error != nil {
_ = jc.Error(errUploadingFileErr, http.StatusInternalServerError) _ = jc.Error(errUploadingFileErr, http.StatusInternalServerError)
h.portal.Logger().Error(errUploadingFile, zap.Error(err)) h.portal.Logger().Error(errUploadingFile, zap.Error(err))
return
} }
jc.Encode(&SmallUploadResponse{ jc.Encode(&SmallUploadResponse{