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-22 23:53:05 +00:00
|
|
|
"github.com/aws/aws-sdk-go-v2/service/s3"
|
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
|
2024-01-22 23:51:09 +00:00
|
|
|
BuildUploadBufferTus(basePath string, preUploadCb TusPreUploadCreateCallback, preFinishCb TusPreFinishResponseCallback) (*tusd.Handler, tusd.DataStore, *s3.Client, 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)
|
2024-01-22 23:52:37 +00:00
|
|
|
GetHash(file io.Reader) ([]byte, int64, error)
|
2024-01-25 00:05:54 +00:00
|
|
|
GetFile(hash []byte, start int64) (io.ReadCloser, int64, 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-20 12:05:27 +00:00
|
|
|
TusUploadExists(hash []byte) (bool, models.TusUpload)
|
2024-01-19 20:51:31 +00:00
|
|
|
CreateTusUpload(hash []byte, uploadID string, uploaderID uint, uploaderIP string, protocol string) (*models.TusUpload, error)
|
|
|
|
TusUploadProgress(uploadID string) error
|
2024-01-22 22:49:03 +00:00
|
|
|
TusUploadCompleted(uploadID string) error
|
2024-01-19 20:51:31 +00:00
|
|
|
DeleteTusUpload(uploadID string) error
|
|
|
|
ScheduleTusUpload(uploadID string, attempt int) error
|
2024-01-19 21:51:41 +00:00
|
|
|
Tus() *tusd.Handler
|
2024-01-25 21:30:35 +00:00
|
|
|
NewFile(hash []byte) File
|
2024-01-19 20:51:31 +00:00
|
|
|
Service
|
2024-01-15 04:52:54 +00:00
|
|
|
}
|