feat: add upload create call
This commit is contained in:
parent
cc5fadeef3
commit
185269afea
|
@ -2,10 +2,12 @@ package s5
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"encoding/hex"
|
||||||
"errors"
|
"errors"
|
||||||
"git.lumeweb.com/LumeWeb/libs5-go/encoding"
|
"git.lumeweb.com/LumeWeb/libs5-go/encoding"
|
||||||
s5interface "git.lumeweb.com/LumeWeb/libs5-go/interfaces"
|
s5interface "git.lumeweb.com/LumeWeb/libs5-go/interfaces"
|
||||||
"git.lumeweb.com/LumeWeb/libs5-go/types"
|
"git.lumeweb.com/LumeWeb/libs5-go/types"
|
||||||
|
"git.lumeweb.com/LumeWeb/portal/db/models"
|
||||||
"git.lumeweb.com/LumeWeb/portal/interfaces"
|
"git.lumeweb.com/LumeWeb/portal/interfaces"
|
||||||
"go.sia.tech/jape"
|
"go.sia.tech/jape"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
|
@ -137,5 +139,18 @@ func (h *HttpHandlerImpl) SmallFileUpload(jc *jape.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tx := h.portal.Database().Create(&models.Upload{
|
||||||
|
Hash: hex.EncodeToString(hash),
|
||||||
|
Size: uint64(bufferSize),
|
||||||
|
Protocol: "s5",
|
||||||
|
UserID: 0,
|
||||||
|
})
|
||||||
|
|
||||||
|
if tx.Error != nil {
|
||||||
|
_ = jc.Error(errUploadingFileErr, http.StatusInternalServerError)
|
||||||
|
h.portal.Logger().Error(errUploadingFile, zap.Error(err))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
jc.Encode(map[string]string{"hash": cidStr})
|
jc.Encode(map[string]string{"hash": cidStr})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue