refactor: swap Protocol for to StorageProtocol

This commit is contained in:
Derrick Hammer 2024-02-17 04:06:16 -05:00
parent b52383b123
commit 97297036c7
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 29 additions and 30 deletions

View File

@ -53,7 +53,7 @@ type TusHandler struct {
tus *tusd.Handler
tusStore tusd.DataStore
s3Client *s3.Client
protocol *S5Protocol
storageProtocol storage.StorageProtocol
}
type TusHandlerParams struct {
@ -65,7 +65,7 @@ type TusHandlerParams struct {
Storage storage.StorageService
Accounts *account.AccountServiceDefault
Metadata metadata.MetadataService
Protocol *S5Protocol
StorageProtocol storage.StorageProtocol
}
func NewTusHandler(params TusHandlerParams) *TusHandler {
@ -77,6 +77,7 @@ func NewTusHandler(params TusHandlerParams) *TusHandler {
storage: params.Storage,
accounts: params.Accounts,
metadata: params.Metadata,
storageProtocol: params.StorageProtocol,
}
}
@ -373,16 +374,14 @@ func (t *TusHandler) uploadTask(ctx context.Context, upload *models.TusUpload) e
return err
}
storageProtocol := GetStorageProtocol(t.protocol)
uploadMeta, err := t.storage.UploadObject(ctx, storageProtocol, nil, &renter.MultiPartUploadParams{
uploadMeta, err := t.storage.UploadObject(ctx, t.storageProtocol, nil, &renter.MultiPartUploadParams{
ReaderFactory: func(start uint, end uint) (io.ReadCloser, error) {
rangeHeader := fmt.Sprintf("bytes=%d-%d", start, end)
ctx = context.WithValue(ctx, "range", rangeHeader)
return tusUpload.GetReader(ctx)
},
Bucket: upload.Protocol,
FileName: "/" + storageProtocol.EncodeFileName(dbHash),
FileName: "/" + t.storageProtocol.EncodeFileName(dbHash),
Size: uint64(info.Size),
}, proof)