dramaling-vocab-learning/backend/DramaLing.Api/Services/Storage/ImageStorageFactory.cs

21 lines
869 B
C#

namespace DramaLing.Api.Services.Storage;
public static class ImageStorageFactory
{
public static IImageStorageService Create(
IConfiguration configuration,
ILogger<IImageStorageService> logger)
{
var provider = configuration["ImageStorage:Provider"]?.ToLower() ?? "local";
return provider switch
{
"local" => new LocalImageStorageService(configuration,
logger as ILogger<LocalImageStorageService>
?? throw new ArgumentException("Invalid logger type")),
"aws" => throw new NotImplementedException("AWS storage not yet implemented"),
"azure" => throw new NotImplementedException("Azure storage not yet implemented"),
_ => throw new NotSupportedException($"Storage provider '{provider}' not supported")
};
}
}