Add support for non-AWS S3 storage endpoints and auth
This commit is contained in:
15
config.go
15
config.go
@@ -44,6 +44,7 @@ type IPFS struct {
|
|||||||
|
|
||||||
type S3 struct {
|
type S3 struct {
|
||||||
Enabled bool `yaml:"enabled"`
|
Enabled bool `yaml:"enabled"`
|
||||||
|
Endpoint string `yaml:"endpoint"`
|
||||||
AccessKey string `yaml:"accessKey"`
|
AccessKey string `yaml:"accessKey"`
|
||||||
Secret string `yaml:"secret"`
|
Secret string `yaml:"secret"`
|
||||||
Bucket string `yaml:"bucket"`
|
Bucket string `yaml:"bucket"`
|
||||||
@@ -75,6 +76,20 @@ func checkConfig(config Config) {
|
|||||||
panic("S3 and IPFS support cannot be enabled at the same time. Choose one.")
|
panic("S3 and IPFS support cannot be enabled at the same time. Choose one.")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if config.S3.Enabled {
|
||||||
|
if config.S3.AccessKey == "" || config.S3.Secret == "" {
|
||||||
|
panic("S3 support requires an access key and secret.")
|
||||||
|
}
|
||||||
|
|
||||||
|
if config.S3.Region == "" || config.S3.Endpoint == "" {
|
||||||
|
panic("S3 support requires a region and endpoint.")
|
||||||
|
}
|
||||||
|
|
||||||
|
if config.S3.Bucket == "" {
|
||||||
|
panic("S3 support requires a bucket created for storing public video segments.")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if !fileExists(config.PrivateHLSPath) {
|
if !fileExists(config.PrivateHLSPath) {
|
||||||
panic(fmt.Sprintf("%s does not exist.", config.PrivateHLSPath))
|
panic(fmt.Sprintf("%s does not exist.", config.PrivateHLSPath))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ ipfs:
|
|||||||
|
|
||||||
s3:
|
s3:
|
||||||
enabled: false
|
enabled: false
|
||||||
|
endpoint: https://s3.us-west-2.amazonaws.com
|
||||||
accessKey: ABC12342069
|
accessKey: ABC12342069
|
||||||
secret: lolomgqwtf49583949
|
secret: lolomgqwtf49583949
|
||||||
region: us-west-2
|
region: us-west-2
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ type S3Storage struct {
|
|||||||
sess *session.Session
|
sess *session.Session
|
||||||
host string
|
host string
|
||||||
|
|
||||||
|
s3Endpoint string
|
||||||
s3Region string
|
s3Region string
|
||||||
s3Bucket string
|
s3Bucket string
|
||||||
s3AccessKey string
|
s3AccessKey string
|
||||||
@@ -26,6 +27,7 @@ type S3Storage struct {
|
|||||||
func (s *S3Storage) Setup(configuration Config) {
|
func (s *S3Storage) Setup(configuration Config) {
|
||||||
log.Println("Setting up S3 for external storage of video...")
|
log.Println("Setting up S3 for external storage of video...")
|
||||||
|
|
||||||
|
s.s3Endpoint = configuration.S3.Endpoint
|
||||||
s.s3Region = configuration.S3.Region
|
s.s3Region = configuration.S3.Region
|
||||||
s.s3Bucket = configuration.S3.Bucket
|
s.s3Bucket = configuration.S3.Bucket
|
||||||
s.s3AccessKey = configuration.S3.AccessKey
|
s.s3AccessKey = configuration.S3.AccessKey
|
||||||
@@ -93,6 +95,8 @@ func (s S3Storage) connectAWS() *session.Session {
|
|||||||
&aws.Config{
|
&aws.Config{
|
||||||
Region: aws.String(s.s3Region),
|
Region: aws.String(s.s3Region),
|
||||||
Credentials: creds,
|
Credentials: creds,
|
||||||
|
Endpoint: aws.String(s.s3Endpoint),
|
||||||
|
S3ForcePathStyle: aws.Bool(true),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user