From cabff5dc081164aa7fdff22eb58e9a3f612c84aa Mon Sep 17 00:00:00 2001 From: Guillaume LEGRAIN Date: Fri, 16 Aug 2024 16:26:44 +0200 Subject: [PATCH] feat(minio): add s3_force_path_style parameters for bucket on minio --- config.go | 5 +++++ manager.go | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/config.go b/config.go index cf553a56..bc10280f 100644 --- a/config.go +++ b/config.go @@ -34,6 +34,7 @@ type s3Config struct { UploadFilePath string `yaml:"upload_file_path"` APIKey string `yaml:"api_key"` APISecret string `yaml:"secret_access_key"` + S3ForcePathStyle bool `yaml:"s3_force_path_style"` } // Config - @@ -84,6 +85,10 @@ func (c *s3Config) validate() error { if len(c.APISecret) == 0 { return fmt.Errorf("missing mandatory key s3.api_secret") } + // Default S3ForcePathStyle to false if not provided + if !c.S3ForcePathStyle { + c.S3ForcePathStyle = false + } return nil } diff --git a/manager.go b/manager.go index 19c13714..2bd78e64 100644 --- a/manager.go +++ b/manager.go @@ -4,6 +4,8 @@ import ( "bytes" "errors" "fmt" + "os" + "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/aws/credentials" @@ -11,7 +13,6 @@ import ( "github.com/aws/aws-sdk-go/service/s3" "github.com/aws/aws-sdk-go/service/s3/s3manager" log "github.com/sirupsen/logrus" - "os" ) type Manager struct { @@ -54,6 +55,7 @@ func (m *Manager) newSession() (*session.Session, error) { config.WithRegion(m.config.S3.Region) config.WithEndpoint(m.config.S3.URL) config.WithMaxRetries(3) + config.WithS3ForcePathStyle(*aws.Bool(m.config.S3.S3ForcePathStyle)) return session.NewSession(config) }