Skip to content

Commit 2965bf6

Browse files
committed
fix: enable path-style S3 addressing for custom endpoints
Enable UsePathStyle when AWS_ENDPOINT_URL is set, fixing compatibility with S3-compatible services like MinIO and LocalStack that require path-style addressing instead of virtual-hosted style.
1 parent 06987ce commit 2965bf6

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

internal/outctx/context.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"context"
99
"errors"
1010
"fmt"
11+
"os"
1112
"path/filepath"
1213
"unsafe"
1314

@@ -79,7 +80,13 @@ func NewS3Context(plugin unsafe.Pointer) (*S3Context, error) {
7980
awsCfg.Credentials = aws.NewCredentialsCache(creds)
8081
}
8182

82-
s3Client := s3.NewFromConfig(awsCfg)
83+
s3Client := s3.NewFromConfig(awsCfg, func(o *s3.Options) {
84+
// Enable path-style addressing for S3-compatible services (MinIO, LocalStack, etc.)
85+
// AWS S3 supports both styles, but custom endpoints typically require path-style.
86+
if os.Getenv("AWS_ENDPOINT_URL") != "" {
87+
o.UsePathStyle = true
88+
}
89+
})
8390

8491
// Confirm bucket exists and test aws credentials.
8592
_, err = s3Client.HeadBucket(context.TODO(), &s3.HeadBucketInput{

0 commit comments

Comments
 (0)