video upload to AWS

This commit is contained in:
2025-03-15 23:35:24 +02:00
parent bb2770e6bd
commit 1d0c56f493
4 changed files with 213 additions and 1 deletions

13
main.go
View File

@@ -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)