refactor: use CreateUpload
This commit is contained in:
parent
5fec2f08ff
commit
c338a41efd
|
@ -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{
|
||||||
|
|
Loading…
Reference in New Issue