feat: add support for ranges in tus s3 store

This commit is contained in:
Derrick Hammer 2024-01-25 09:50:17 -05:00
parent d91355796b
commit e1556f2f68
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 11 additions and 1 deletions

View File

@ -5,6 +5,7 @@ import (
"context"
"encoding/hex"
"errors"
"fmt"
"git.lumeweb.com/LumeWeb/libs5-go/encoding"
"git.lumeweb.com/LumeWeb/libs5-go/types"
"git.lumeweb.com/LumeWeb/portal/api/middleware"
@ -592,7 +593,16 @@ func (s *StorageServiceImpl) GetFile(hash []byte, start int64) (io.ReadCloser, i
}
info, _ := upload.GetInfo(context.Background())
reader, err := upload.GetReader(context.Background())
ctx := context.Background()
if start > 0 {
endPosition := start + info.Size - 1
rangeHeader := fmt.Sprintf("bytes=%d-%d", start, endPosition)
ctx = context.WithValue(ctx, "range", rangeHeader)
}
reader, err := upload.GetReader(ctx)
return reader, info.Size, err
}