From 06b5729b95cd5b42c8e3ac7659f499756d04a9a5 Mon Sep 17 00:00:00 2001 From: Brandon Liu Date: Fri, 5 Jan 2024 14:55:05 +0800 Subject: [PATCH] Don't force aws sdk v2 for s3 buckets [#112] (#113) Don't force aws sdk v2 for s3 buckets [#112] * this is to allow sdk v1 query params like s3ForcePathStyle, to work with Minio and other storage systems: see https://gocloud.dev/howto/blob/#s3-compatible --- pmtiles/bucket.go | 11 ----------- pmtiles/bucket_test.go | 6 ------ 2 files changed, 17 deletions(-) diff --git a/pmtiles/bucket.go b/pmtiles/bucket.go index c836ec2..d860288 100644 --- a/pmtiles/bucket.go +++ b/pmtiles/bucket.go @@ -97,17 +97,6 @@ func NormalizeBucketKey(bucket string, prefix string, key string) (string, strin } } - if strings.HasPrefix(bucket, "s3") { - u, err := url.Parse(bucket) - if err != nil { - fmt.Println("Error parsing URL:", err) - return "", "", err - } - values := u.Query() - values.Set("awssdk", "v2") - u.RawQuery = values.Encode() - return u.String(), key, nil - } return bucket, key, nil } diff --git a/pmtiles/bucket_test.go b/pmtiles/bucket_test.go index 9e009e7..2039a8f 100644 --- a/pmtiles/bucket_test.go +++ b/pmtiles/bucket_test.go @@ -29,12 +29,6 @@ func TestNormalizeHttp(t *testing.T) { assert.Equal(t, "http://example.com/foo", bucket) } -func TestNormalizeAwsSdkVersion(t *testing.T) { - bucket, key, _ := NormalizeBucketKey("s3://mybucket?awssdk=v1&endpoint=https://foo.bar", "", "abc") - assert.Equal(t, "abc", key) - assert.Equal(t, "s3://mybucket?awssdk=v2&endpoint=https%3A%2F%2Ffoo.bar", bucket) -} - func TestNormalizePathPrefixServer(t *testing.T) { bucket, key, _ := NormalizeBucketKey("", "../foo", "") assert.Equal(t, "", key)