Support separate S3 serving endpoint (#91)

* Add s3 serving endpoint config. Fixes #90

* Move CDN endpoint generation to GenerateRemotePlaylist

* Include HLS path

* Add docs and config

* Prefer sprintf to string concatenation

* Use config method

* gofmt
This commit is contained in:
Matt Steele
2020-07-28 15:17:39 -05:00
committed by GitHub
parent cb04826173
commit 87636a4183
4 changed files with 24 additions and 13 deletions

View File

@@ -2,6 +2,7 @@ package storageproviders
import (
"bufio"
"fmt"
"os"
"strings"
@@ -21,12 +22,13 @@ type S3Storage struct {
sess *session.Session
host string
s3Endpoint string
s3Region string
s3Bucket string
s3AccessKey string
s3Secret string
s3ACL string
s3Endpoint string
s3ServingEndpoint string
s3Region string
s3Bucket string
s3AccessKey string
s3Secret string
s3ACL string
}
//Setup sets up the s3 storage for saving the video to s3
@@ -34,6 +36,7 @@ func (s *S3Storage) Setup() error {
log.Trace("Setting up S3 for external storage of video...")
s.s3Endpoint = config.Config.S3.Endpoint
s.s3ServingEndpoint = config.Config.S3.ServingEndpoint
s.s3Region = config.Config.S3.Region
s.s3Bucket = config.Config.S3.Bucket
s.s3AccessKey = config.Config.S3.AccessKey
@@ -90,6 +93,8 @@ func (s *S3Storage) GenerateRemotePlaylist(playlist string, variant models.Varia
fullRemotePath := variant.GetSegmentForFilename(line)
if fullRemotePath == nil {
line = ""
} else if s.s3ServingEndpoint != "" {
line = fmt.Sprintf("%s/%s/%s", s.s3ServingEndpoint, config.Config.GetPrivateHLSSavePath(), fullRemotePath.RelativeUploadPath)
} else {
line = fullRemotePath.RemoteID
}