backend: s3: add option to choose bucket lookup type.

Certain S3 compatible storage providers does not support path style
bucket lookup anymore, add config option to manually specify DNS style
for minio.

Signed-off-by: imi415 <imi415@imi.moe>
This commit is contained in:
imi415
2026-07-08 10:59:29 +08:00
parent f492dc707d
commit 03999af740
4 changed files with 20 additions and 1 deletions
+3
View File
@@ -14,6 +14,9 @@ type = 'fs'
[storage.fs]
root = './data'
[storage.s3]
bucket-lookup = "auto"
[limits]
max-site-size = '128MB'
max-manifest-size = '1MB'
+1
View File
@@ -30,6 +30,7 @@ root = "./data"
[storage.s3] # non-default section
endpoint = "play.min.io"
bucket-lookup = "auto"
access-key-id = "Q3AM3UQ867SPQQA43P2F"
secret-access-key = "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG"
region = "us-east-1"
+15 -1
View File
@@ -155,13 +155,27 @@ func makeCacheOptions[K comparable, V any](
}
func NewS3Backend(ctx context.Context, config *S3Config) (*S3Backend, error) {
var bucketLookup minio.BucketLookupType
switch config.BucketLookup {
case "auto":
bucketLookup = minio.BucketLookupAuto
case "path":
bucketLookup = minio.BucketLookupPath
case "dns":
bucketLookup = minio.BucketLookupDNS
default:
return nil, fmt.Errorf("unknown bucket lookup type: %s", config.BucketLookup)
}
client, err := minio.New(config.Endpoint, &minio.Options{
Creds: credentials.NewStaticV4(
config.AccessKeyID,
config.SecretAccessKey,
"",
),
Secure: !config.Insecure,
Secure: !config.Insecure,
BucketLookup: bucketLookup,
})
if err != nil {
return nil, err
+1
View File
@@ -112,6 +112,7 @@ type FSConfig struct {
type S3Config struct {
Endpoint string `toml:"endpoint"`
Insecure bool `toml:"insecure"`
BucketLookup string `toml:"bucket-lookup" default:"auto"`
AccessKeyID string `toml:"access-key-id"`
SecretAccessKey string `toml:"secret-access-key"`
Region string `toml:"region"`