Add option forcePathStyle for s3 deployment

This commit is contained in:
louie
2025-03-21 21:59:42 +08:00
committed by Caelan
parent 6065d5636e
commit 7d65b9ef15
2 changed files with 12 additions and 3 deletions

View File

@@ -23,6 +23,8 @@ public class S3DownloadOptions : RepositoryOptions, IObjectDownloadOptions
public string Bucket { get; set; }
public string Prefix { get; set; }
public bool ForcePathStyle { get; set; }
}
public class S3UploadOptions : S3DownloadOptions, IObjectUploadOptions
@@ -98,8 +100,8 @@ public class S3Repository : ObjectRepository<S3DownloadOptions, S3UploadOptions,
bool disableSigning = false;
var config = new AmazonS3Config() {
ServiceURL = options.Endpoint,
ForcePathStyle = true, // support for MINIO
Timeout = TimeSpan.FromMinutes(options.Timeout),
ForcePathStyle = options.ForcePathStyle,
Timeout = TimeSpan.FromMinutes(options.Timeout)
};
if (options.Endpoint != null) {
@@ -214,4 +216,4 @@ public class S3Repository : ObjectRepository<S3DownloadOptions, S3UploadOptions,
} catch { }
}
}
}
}

View File

@@ -16,6 +16,8 @@ public class S3BaseCommand : OutputCommand
public string Prefix { get; private set; }
public bool ForcePathStyle { get; private set; }
public double Timeout { get; private set; }
protected S3BaseCommand(string name, string description)
@@ -56,6 +58,11 @@ public class S3BaseCommand : OutputCommand
.SetDescription("Prefix to the S3 url.")
.SetArgumentHelpName("PREFIX");
AddOption<bool>((v) => ForcePathStyle = v, "--forcePathStyle")
.SetDescription("Force a path-style endpoint to be used where the bucket name is part of the path.")
.SetArgumentHelpName("BOOL")
.SetDefault(true);
AddOption<double>((v) => Timeout = v, "--timeout")
.SetDescription("Network timeout in minutes.")
.SetArgumentHelpName("MINUTES")