From 6c60dae7437f69d5142c1415f1a24245c502d6db Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Sun, 10 Mar 2024 11:53:24 -0400 Subject: [PATCH] fix: if the render end is 0, ensure the range header is valid syntax and skip it --- api/s5/s5.go | 8 +++++++- protocols/s5/tus.go | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/api/s5/s5.go b/api/s5/s5.go index 5a8e067..7e1b33f 100644 --- a/api/s5/s5.go +++ b/api/s5/s5.go @@ -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{ 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{ Bucket: aws.String(s.config.Config().Core.Storage.S3.BufferBucket), Key: aws.String(cid), diff --git a/protocols/s5/tus.go b/protocols/s5/tus.go index b432571..ff66e59 100644 --- a/protocols/s5/tus.go +++ b/protocols/s5/tus.go @@ -390,7 +390,13 @@ func (t *TusHandler) uploadTask(hash []byte) error { 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) + 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) return tusUpload.GetReader(ctx) },