summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabe Kangas <gabek@real-ity.com>2021-10-05 16:00:03 -0700
committerGabe Kangas <gabek@real-ity.com>2021-10-05 16:45:53 -0700
commit390b3fc468e5fb8fd02e0b3ec53117e7298e36d2 (patch)
treefac7a36c99e96d51a52e13f8176a3eba066afc90
parent7860fe78dc56dc5b2b6e11011dc1e842fff57890 (diff)
Fix the destination path. Closes #1455v0.0.10
-rw-r--r--core/storageproviders/s3Storage.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/core/storageproviders/s3Storage.go b/core/storageproviders/s3Storage.go
index 7bb014a08..27b62c7b7 100644
--- a/core/storageproviders/s3Storage.go
+++ b/core/storageproviders/s3Storage.go
@@ -5,6 +5,7 @@ import (
"fmt"
"os"
"path/filepath"
+ "strings"
"github.com/owncast/owncast/core/data"
"github.com/owncast/owncast/core/playlist"
@@ -130,11 +131,16 @@ func (s *S3Storage) Save(filePath string, retryCount int) (string, error) {
}
defer file.Close()
+ // Convert the local path to the variant/file path by stripping the local storage location.
+ normalizedPath := strings.TrimPrefix(filePath, config.HLSStoragePath)
+ // Build the remote path by adding the "hls" path prefix.
+ remotePath := strings.Join([]string{"hls", normalizedPath}, "")
+
maxAgeSeconds := utils.GetCacheDurationSecondsForPath(filePath)
cacheControlHeader := fmt.Sprintf("max-age=%d", maxAgeSeconds)
uploadInput := &s3manager.UploadInput{
Bucket: aws.String(s.s3Bucket), // Bucket to be used
- Key: aws.String(filePath), // Name of the file to be saved
+ Key: aws.String(remotePath), // Name of the file to be saved
Body: file, // File
CacheControl: &cacheControlHeader,
}