pls fucking work

This commit is contained in:
2026-08-22 21:08:02 +02:00
parent 2b4d07785a
commit c5fd977c3d
2 changed files with 0 additions and 32 deletions
-1
View File
@@ -52,7 +52,6 @@ func main() {
Bucket: cfg.StorageBucket,
UseSSL: cfg.StorageUseSSL,
PublicUseSSL: true,
CORSOrigins: cfg.CORSOrigin,
})
if err != nil {
log.Fatalf("storage unavailable: %v", err)
-31
View File
@@ -4,11 +4,9 @@ import (
"context"
"fmt"
"io"
"strings"
"time"
"github.com/minio/minio-go/v7"
"github.com/minio/minio-go/v7/pkg/cors"
"github.com/minio/minio-go/v7/pkg/credentials"
)
@@ -20,7 +18,6 @@ type Config struct {
Bucket string
UseSSL bool
PublicUseSSL bool
CORSOrigins string
}
type ObjectInfo struct {
@@ -44,7 +41,6 @@ type MinIO struct {
client *minio.Client
publicClient *minio.Client
bucket string
corsOrigins string
}
func NewMinIO(config Config) (*MinIO, error) {
@@ -74,7 +70,6 @@ func NewMinIO(config Config) (*MinIO, error) {
client: client,
publicClient: publicClient,
bucket: config.Bucket,
corsOrigins: config.CORSOrigins,
}, nil
}
@@ -91,32 +86,6 @@ func (s *MinIO) EnsureBucket(ctx context.Context) error {
}
}
}
origins := make([]string, 0)
for _, origin := range strings.Split(s.corsOrigins, ",") {
if value := strings.TrimSpace(origin); value != "" {
origins = append(origins, value)
}
}
if len(origins) == 0 {
origins = []string{"*"}
}
if err := s.client.SetBucketCors(ctx, s.bucket, cors.NewConfig([]cors.Rule{{
ID: "studio-browser-uploads",
AllowedOrigin: origins,
AllowedMethod: []string{"GET", "PUT", "POST", "DELETE", "HEAD"},
AllowedHeader: []string{
"Content-Type",
"x-amz-acl",
"x-amz-date",
"x-amz-content-sha256",
"Authorization",
"Origin",
},
ExposeHeader: []string{"ETag", "x-amz-request-id", "x-amz-id-2"},
MaxAgeSeconds: 3600,
}})); err != nil {
return fmt.Errorf("configure object storage CORS: %w", err)
}
return nil
}