2024-01-15 04:52:54 +00:00
|
|
|
package interfaces
|
|
|
|
|
2024-01-16 06:01:57 +00:00
|
|
|
import (
|
|
|
|
"git.lumeweb.com/LumeWeb/portal/db/models"
|
2024-01-19 20:51:31 +00:00
|
|
|
tusd "github.com/tus/tusd/v2/pkg/handler"
|
2024-01-16 06:01:57 +00:00
|
|
|
"io"
|
|
|
|
)
|
2024-01-15 04:52:54 +00:00
|
|
|
|
2024-01-19 20:51:31 +00:00
|
|
|
type TusPreUploadCreateCallback func(hook tusd.HookEvent) (tusd.HTTPResponse, tusd.FileInfoChanges, error)
|
|
|
|
type TusPreFinishResponseCallback func(hook tusd.HookEvent) (tusd.HTTPResponse, error)
|
|
|
|
|
2024-01-15 04:52:54 +00:00
|
|
|
type StorageService interface {
|
2024-01-19 20:51:31 +00:00
|
|
|
Portal() Portal
|
|
|
|
PutFileSmall(file io.ReadSeeker, bucket string, generateProof bool) ([]byte, error)
|
|
|
|
PutFile(file io.Reader, bucket string, hash []byte) error
|
|
|
|
BuildUploadBufferTus(basePath string, preUploadCb TusPreUploadCreateCallback, preFinishCb TusPreFinishResponseCallback) (*tusd.Handler, tusd.DataStore, error)
|
2024-01-16 06:01:57 +00:00
|
|
|
FileExists(hash []byte) (bool, models.Upload)
|
2024-01-19 20:51:31 +00:00
|
|
|
GetHashSmall(file io.ReadSeeker) ([]byte, error)
|
|
|
|
GetHash(file io.Reader) ([]byte, error)
|
2024-01-17 19:46:22 +00:00
|
|
|
CreateUpload(hash []byte, uploaderID uint, uploaderIP string, size uint64, protocol string) (*models.Upload, error)
|
2024-01-19 20:51:31 +00:00
|
|
|
TusUploadExists(hash []byte) (bool, models.Upload)
|
|
|
|
CreateTusUpload(hash []byte, uploadID string, uploaderID uint, uploaderIP string, protocol string) (*models.TusUpload, error)
|
|
|
|
TusUploadProgress(uploadID string) error
|
|
|
|
DeleteTusUpload(uploadID string) error
|
|
|
|
ScheduleTusUpload(uploadID string, attempt int) error
|
2024-01-19 21:51:41 +00:00
|
|
|
Tus() *tusd.Handler
|
2024-01-19 20:51:31 +00:00
|
|
|
Service
|
2024-01-15 04:52:54 +00:00
|
|
|
}
|