Added S3 support
continuous-integration/drone/pr Build is passing

This commit is contained in:
Khwezi Mngoma
2026-05-19 10:23:36 +02:00
parent da141311ff
commit f245bc94e1
4 changed files with 83 additions and 0 deletions
+31
View File
@@ -0,0 +1,31 @@
using Amazon.Runtime;
using LiteCharms.Features.S3;
using LiteCharms.Features.S3.Configuration;
namespace LiteCharms.Features.Extensions;
public static class S3
{
public static IServiceCollection AddGarageS3(this IServiceCollection services, IConfiguration configuration)
{
var optionsSection = configuration.GetSection(nameof(S3Settings));
services.Configure<S3Settings>(optionsSection);
var options = optionsSection.Get<S3Settings>()
?? throw new InvalidOperationException("S3 configuration section is missing.");
var credentials = new BasicAWSCredentials(options.AccessKey, options.SecretKey);
var s3Config = new AmazonS3Config
{
ServiceURL = options.ServiceUrl,
AuthenticationRegion = options.Region,
ForcePathStyle = true,
};
services.AddSingleton<IAmazonS3>(new AmazonS3Client(credentials, s3Config));
services.AddScoped<S3Service>();
return services;
}
}