Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions src/FubarDev.FtpServer.FileSystem.S3/S3FileSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
8 changes: 8 additions & 0 deletions src/FubarDev.FtpServer.FileSystem.S3/S3FileSystemOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ public class S3FileSystemOptions
/// </remarks>
public string? BucketRegion { get; set; }

/// <summary>
/// Gets or sets the S3 service URL.
/// </summary>
/// <remarks>
/// Takes precedence over BucketRegion.
/// </remarks>
public string? ServiceUrl { get; set; }

/// <summary>
/// Gets or sets the S3 bucket name.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public S3FileSystemProvider(IOptions<S3FileSystemOptions> 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");
}
Expand Down