Browse Source

S3 headers (#2830)

* change s3 headers for playlist files

* clean up code

---------

Co-authored-by: Gabe Kangas <gabek@real-ity.com>
pull/2841/head
Jacob Wrenn 2 years ago committed by GitHub
parent
commit
7e76ee63e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      core/storageproviders/s3Storage.go

10
core/storageproviders/s3Storage.go

@ -5,6 +5,7 @@ import ( @@ -5,6 +5,7 @@ import (
"fmt"
"net/http"
"os"
"path"
"path/filepath"
"strings"
"time"
@ -149,6 +150,7 @@ func (s *S3Storage) Save(filePath string, retryCount int) (string, error) { @@ -149,6 +150,7 @@ func (s *S3Storage) Save(filePath string, retryCount int) (string, error) {
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(remotePath), // Name of the file to be saved
@ -156,6 +158,14 @@ func (s *S3Storage) Save(filePath string, retryCount int) (string, error) { @@ -156,6 +158,14 @@ func (s *S3Storage) Save(filePath string, retryCount int) (string, error) {
CacheControl: &cacheControlHeader,
}
if path.Ext(filePath) == ".m3u8" {
noCacheHeader := "no-cache, no-store, must-revalidate"
contentType := "application/x-mpegURL"
uploadInput.CacheControl = &noCacheHeader
uploadInput.ContentType = &contentType
}
if s.s3ACL != "" {
uploadInput.ACL = aws.String(s.s3ACL)
} else {

Loading…
Cancel
Save