Skip to content

Support S3 Compatible Blob Storage Providers #22962

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 6 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Add ServiceURL configuration for S3-compatible APIs
- Introduced a new property `ServiceURL` in `AwsBlobProviderConfiguration` to allow custom service URLs for S3-compatible APIs like MinIO and DigitalOcean Spaces.
- Updated `AwsBlobProviderConfigurationNames` to include the new `ServiceURL` constant.
- Modified `DefaultAmazonS3ClientFactory` to utilize the `ServiceURL` when creating the S3 client configuration, enabling support for custom endpoints.
  • Loading branch information
enisn committed May 26, 2025
commit 24c27154d9d2ed0499640aa5e56a31c5ff6304d2
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,15 @@ public string Region {
set => _containerConfiguration.SetConfiguration(AwsBlobProviderConfigurationNames.Region, Check.NotNull(value, nameof(value)));
}

/// <summary>
/// Custom service URL for S3-compatible APIs (e.g., MinIO, DigitalOcean Spaces).
/// If not specified, the default AWS S3 service URL will be used based on the region.
/// </summary>
public string? ServiceURL {
get => _containerConfiguration.GetConfigurationOrDefault<string>(AwsBlobProviderConfigurationNames.ServiceURL);
set => _containerConfiguration.SetConfiguration(AwsBlobProviderConfigurationNames.ServiceURL, value);
}

/// <summary>
/// This name may only contain lowercase letters, numbers, and hyphens, and must begin with a letter or a number.
/// Each hyphen must be preceded and followed by a non-hyphen character.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public static class AwsBlobProviderConfigurationNames
public const string Name = "Aws.Name";
public const string Policy = "Aws.Policy";
public const string Region = "Aws.Region";
public const string ServiceURL = "Aws.ServiceURL";
public const string ContainerName = "Aws.ContainerName";
public const string CreateContainerIfNotExists = "Aws.CreateContainerIfNotExists";
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,30 +31,47 @@ public virtual async Task<AmazonS3Client> GetAmazonS3Client(
AwsBlobProviderConfiguration configuration)
{
var region = RegionEndpoint.GetBySystemName(configuration.Region);
var clientConfig = CreateS3ClientConfig(configuration, region);

if (configuration.UseCredentials)
{
var awsCredentials = GetAwsCredentials(configuration);
return awsCredentials == null
? new AmazonS3Client(region)
: new AmazonS3Client(awsCredentials, region);
? new AmazonS3Client(clientConfig)
: new AmazonS3Client(awsCredentials, clientConfig);
}

if (configuration.UseTemporaryCredentials)
{
return new AmazonS3Client(await GetTemporaryCredentialsAsync(configuration), region);
return new AmazonS3Client(await GetTemporaryCredentialsAsync(configuration), clientConfig);
}

if (configuration.UseTemporaryFederatedCredentials)
{
return new AmazonS3Client(await GetTemporaryFederatedCredentialsAsync(configuration),
region);
clientConfig);
}

Check.NotNullOrWhiteSpace(configuration.AccessKeyId, nameof(configuration.AccessKeyId));
Check.NotNullOrWhiteSpace(configuration.SecretAccessKey, nameof(configuration.SecretAccessKey));

return new AmazonS3Client(configuration.AccessKeyId, configuration.SecretAccessKey, region);
return new AmazonS3Client(configuration.AccessKeyId, configuration.SecretAccessKey, clientConfig);
}

protected virtual AmazonS3Config CreateS3ClientConfig(AwsBlobProviderConfiguration configuration, RegionEndpoint region)
{
var clientConfig = new AmazonS3Config
{
RegionEndpoint = region
};

if (!configuration.ServiceURL.IsNullOrWhiteSpace())
{
clientConfig.ServiceURL = configuration.ServiceURL;
clientConfig.ForcePathStyle = true; // Required for most S3-compatible services
}

return clientConfig;
}

protected virtual AWSCredentials? GetAwsCredentials(
Expand Down