video upload to AWS
This commit is contained in:
13
main.go
13
main.go
@@ -1,6 +1,9 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/aws/aws-sdk-go-v2/config"
|
||||
"github.com/aws/aws-sdk-go-v2/service/s3"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
@@ -17,6 +20,7 @@ type apiConfig struct {
|
||||
platform string
|
||||
filepathRoot string
|
||||
assetsRoot string
|
||||
s3Client *s3.Client
|
||||
s3Bucket string
|
||||
s3Region string
|
||||
s3CfDistribution string
|
||||
@@ -98,6 +102,15 @@ func main() {
|
||||
log.Fatalf("Couldn't create assets directory: %v", err)
|
||||
}
|
||||
|
||||
awsCfg, err := config.LoadDefaultConfig(context.Background(), config.WithRegion(cfg.s3Region))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
client := s3.NewFromConfig(awsCfg)
|
||||
|
||||
cfg.s3Client = client
|
||||
|
||||
mux := http.NewServeMux()
|
||||
appHandler := http.StripPrefix("/app", http.FileServer(http.Dir(filepathRoot)))
|
||||
mux.Handle("/app/", appHandler)
|
||||
|
||||
Reference in New Issue
Block a user