fix: if the render end is 0, ensure the range header is valid syntax and skip it

This commit is contained in:
Derrick Hammer 2024-03-10 11:53:24 -04:00
parent f56377df2b
commit 6c60dae743
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
2 changed files with 14 additions and 2 deletions

View File

@ -2059,7 +2059,13 @@ func (s *S5API) pinImportCronJob(cid string, url string, proofUrl string, userId
upload, err := s.storage.UploadObject(ctx, s5.GetStorageProtocol(s.protocol), nil, &renter.MultiPartUploadParams{ upload, err := s.storage.UploadObject(ctx, s5.GetStorageProtocol(s.protocol), nil, &renter.MultiPartUploadParams{
ReaderFactory: func(start uint, end uint) (io.ReadCloser, error) { ReaderFactory: func(start uint, end uint) (io.ReadCloser, error) {
rangeHeader := fmt.Sprintf("bytes=%d-%d", start, end) rangeHeader := "bytes=%d-"
if end != 0 {
rangeHeader += "%d"
rangeHeader = fmt.Sprintf("bytes=%d-%d", start, end)
} else {
rangeHeader = fmt.Sprintf("bytes=%d-", start)
}
object, err := client.GetObject(ctx, &s3.GetObjectInput{ object, err := client.GetObject(ctx, &s3.GetObjectInput{
Bucket: aws.String(s.config.Config().Core.Storage.S3.BufferBucket), Bucket: aws.String(s.config.Config().Core.Storage.S3.BufferBucket),
Key: aws.String(cid), Key: aws.String(cid),

View File

@ -390,7 +390,13 @@ func (t *TusHandler) uploadTask(hash []byte) error {
uploadMeta, err := t.storage.UploadObject(ctx, t.storageProtocol, nil, &renter.MultiPartUploadParams{ uploadMeta, err := t.storage.UploadObject(ctx, t.storageProtocol, nil, &renter.MultiPartUploadParams{
ReaderFactory: func(start uint, end uint) (io.ReadCloser, error) { ReaderFactory: func(start uint, end uint) (io.ReadCloser, error) {
rangeHeader := fmt.Sprintf("bytes=%d-%d", start, end) rangeHeader := "bytes=%d-"
if end != 0 {
rangeHeader += "%d"
rangeHeader = fmt.Sprintf("bytes=%d-%d", start, end)
} else {
rangeHeader = fmt.Sprintf("bytes=%d-", start)
}
ctx = context.WithValue(ctx, "range", rangeHeader) ctx = context.WithValue(ctx, "range", rangeHeader)
return tusUpload.GetReader(ctx) return tusUpload.GetReader(ctx)
}, },