Skip to content

Commit d7227c3

Browse files
committed
Add UseAccelerateEndpoint to IAWSS3BucketClientOptions and handle it in AmazonS3ClientFactory.cs
1 parent 20fbfae commit d7227c3

File tree

4 files changed

+17
-2
lines changed

4 files changed

+17
-2
lines changed

src/ImageSharp.Web.Providers.AWS/AmazonS3ClientFactory.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public static AmazonS3Client CreateClient(IAWSS3BucketClientOptions options)
2323
{
2424
// AccessKey can be empty.
2525
// AccessSecret can be empty.
26+
// PathStyle endpoint doesn't support AccelerateEndpoint.
2627
AmazonS3Config config = new() { ServiceURL = options.Endpoint, ForcePathStyle = true, AuthenticationRegion = options.Region };
2728
return new AmazonS3Client(options.AccessKey, options.AccessSecret, config);
2829
}
@@ -31,12 +32,14 @@ public static AmazonS3Client CreateClient(IAWSS3BucketClientOptions options)
3132
// AccessSecret can be empty.
3233
Guard.NotNullOrWhiteSpace(options.Region, nameof(options.Region));
3334
var region = RegionEndpoint.GetBySystemName(options.Region);
34-
return new AmazonS3Client(options.AccessKey, options.AccessSecret, region);
35+
AmazonS3Config config = new() { RegionEndpoint = region, UseAccelerateEndpoint = options.UseAccelerateEndpoint };
36+
return new AmazonS3Client(options.AccessKey, options.AccessSecret, config);
3537
}
3638
else if (!string.IsNullOrWhiteSpace(options.Region))
3739
{
3840
var region = RegionEndpoint.GetBySystemName(options.Region);
39-
return new AmazonS3Client(region);
41+
AmazonS3Config config = new() { RegionEndpoint = region, UseAccelerateEndpoint = options.UseAccelerateEndpoint };
42+
return new AmazonS3Client(config);
4043
}
4144
else
4245
{

src/ImageSharp.Web.Providers.AWS/Caching/AWSS3StorageCacheOptions.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,8 @@ public class AWSS3StorageCacheOptions : IAWSS3BucketClientOptions
2222

2323
/// <inheritdoc/>
2424
public string Endpoint { get; set; }
25+
26+
/// <inheritdoc/>
27+
public bool UseAccelerateEndpoint { get; set; }
2528
}
2629
}

src/ImageSharp.Web.Providers.AWS/IAWSS3BucketClientOptions.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,11 @@ internal interface IAWSS3BucketClientOptions
3737
/// to be set to localhost.
3838
/// </summary>
3939
string Endpoint { get; set; }
40+
41+
/// <summary>
42+
/// Gets or sets a value indicating whether the S3 accelerate endpoint is used.
43+
/// The feature must be enabled on the bucket. Follow AWS instruction on <see href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/transfer-acceleration.html"/>.
44+
/// </summary>
45+
bool UseAccelerateEndpoint { get; set; }
4046
}
4147
}

src/ImageSharp.Web.Providers.AWS/Providers/AWSS3StorageImageProviderOptions.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,8 @@ public class AWSS3BucketClientOptions : IAWSS3BucketClientOptions
3535

3636
/// <inheritdoc/>
3737
public string Endpoint { get; set; }
38+
39+
/// <inheritdoc/>
40+
public bool UseAccelerateEndpoint { get; set; }
3841
}
3942
}

0 commit comments

Comments
 (0)