1
0
Fork 0

Support non-AWS S3 URL formats in S3Client

master
Jason Tackaberry 9 months ago
parent e60a0b54fc
commit 8525b0bf7c
No known key found for this signature in database
GPG Key ID: 47A5F9BF12496033

@ -4,6 +4,7 @@ import (
"context"
"fmt"
"io"
"strings"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/credentials"
@ -53,7 +54,16 @@ func NewS3Client(endpoint, region, accessKey, secretKey, bucket, key string, for
// String returns a string representation of the S3Client.
func (s *S3Client) String() string {
if s.endpoint == "" || strings.HasSuffix(s.endpoint, "amazonaws.com") {
// Native Amazon S3, use AWS's S3 URL format
return fmt.Sprintf("s3://%s/%s", s.bucket, s.key)
} else if !s.forcePathStyle {
// Endpoint specified but not using path style (e.g. Wasabi)
return fmt.Sprintf("s3://%s.%s/%s", s.bucket, s.endpoint, s.key)
} else {
// Endpoint specified and using path style (e.g. MinIO)
return fmt.Sprintf("s3://%s/%s/%s", s.endpoint, s.bucket, s.key)
}
}
// Upload uploads data to S3.

Loading…
Cancel
Save