diff --git a/src/FubarDev.FtpServer.FileSystem.S3/S3FileSystem.cs b/src/FubarDev.FtpServer.FileSystem.S3/S3FileSystem.cs
index d164328d..3e310aaa 100644
--- a/src/FubarDev.FtpServer.FileSystem.S3/S3FileSystem.cs
+++ b/src/FubarDev.FtpServer.FileSystem.S3/S3FileSystem.cs
@@ -34,10 +34,19 @@ public sealed class S3FileSystem : IUnixFileSystem
public S3FileSystem(S3FileSystemOptions options, string rootDirectory)
{
_options = options;
- _client = new AmazonS3Client(
- options.AwsAccessKeyId,
- options.AwsSecretAccessKey,
- RegionEndpoint.GetBySystemName(options.BucketRegion));
+
+ var config = new AmazonS3Config();
+
+ if (!string.IsNullOrEmpty(options.ServiceUrl))
+ {
+ config.ServiceURL = options.ServiceUrl;
+ }
+ else
+ {
+ config.RegionEndpoint = RegionEndpoint.GetBySystemName(options.BucketRegion);
+ }
+
+ _client = new AmazonS3Client(options.AwsAccessKeyId, options.AwsSecretAccessKey, config);
Root = new S3DirectoryEntry(rootDirectory, true);
_transferUtility = new TransferUtility(_client);
}
diff --git a/src/FubarDev.FtpServer.FileSystem.S3/S3FileSystemOptions.cs b/src/FubarDev.FtpServer.FileSystem.S3/S3FileSystemOptions.cs
index 5825b5bd..8fd14b1e 100644
--- a/src/FubarDev.FtpServer.FileSystem.S3/S3FileSystemOptions.cs
+++ b/src/FubarDev.FtpServer.FileSystem.S3/S3FileSystemOptions.cs
@@ -32,6 +32,14 @@ public class S3FileSystemOptions
///
public string? BucketRegion { get; set; }
+ ///
+ /// Gets or sets the S3 service URL.
+ ///
+ ///
+ /// Takes precedence over BucketRegion.
+ ///
+ public string? ServiceUrl { get; set; }
+
///
/// Gets or sets the S3 bucket name.
///
diff --git a/src/FubarDev.FtpServer.FileSystem.S3/S3FileSystemProvider.cs b/src/FubarDev.FtpServer.FileSystem.S3/S3FileSystemProvider.cs
index 8f31534d..39f68991 100644
--- a/src/FubarDev.FtpServer.FileSystem.S3/S3FileSystemProvider.cs
+++ b/src/FubarDev.FtpServer.FileSystem.S3/S3FileSystemProvider.cs
@@ -31,7 +31,7 @@ public S3FileSystemProvider(IOptions options, IAccountDirec
if (string.IsNullOrEmpty(_options.AwsAccessKeyId)
|| string.IsNullOrEmpty(_options.AwsSecretAccessKey)
|| string.IsNullOrEmpty(_options.BucketName)
- || string.IsNullOrEmpty(_options.BucketRegion))
+ || (string.IsNullOrEmpty(_options.BucketRegion) && string.IsNullOrEmpty(_options.ServiceUrl)))
{
throw new ArgumentException("S3 Credentials have not been set correctly");
}