feat(storage): support a object storage custom path prefix

This commit is contained in:
Gabe Kangas
2023-08-02 13:35:47 -07:00
parent d5c54aacc1
commit 1a7b6b99d5
7 changed files with 44 additions and 4 deletions

View File

@@ -13,7 +13,7 @@ import (
)
// rewriteRemotePlaylist will take a local playlist and rewrite it to have absolute URLs to remote locations.
func rewriteRemotePlaylist(localFilePath, remoteServingEndpoint string) error {
func rewriteRemotePlaylist(localFilePath, remoteServingEndpoint, pathPrefix string) error {
f, err := os.Open(localFilePath) // nolint
if err != nil {
log.Fatalln(err)
@@ -25,7 +25,14 @@ func rewriteRemotePlaylist(localFilePath, remoteServingEndpoint string) error {
}
for _, item := range p.Variants {
item.URI = remoteServingEndpoint + filepath.Join("/hls", item.URI)
// Determine the final path to this playlist.
var finalPath string
if pathPrefix != "" {
finalPath = filepath.Join(pathPrefix, "/hls")
} else {
finalPath = "/hls"
}
item.URI = remoteServingEndpoint + filepath.Join(finalPath, item.URI)
}
publicPath := filepath.Join(config.HLSStoragePath, filepath.Base(localFilePath))