Skip to content

Instantly share code, notes, and snippets.

@gavilanch
Last active January 20, 2020 12:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gavilanch/955dffda61629651f757678eca074f6d to your computer and use it in GitHub Desktop.
Save gavilanch/955dffda61629651f757678eca074f6d to your computer and use it in GitHub Desktop.
services.AddScoped<IFileStorageService>((serviceProvider) =>
{
var env = serviceProvider.GetRequiredService<IWebHostEnvironment>();
var configuration = serviceProvider.GetRequiredService<IConfiguration>();
if (env.IsDevelopment())
{
var httpContextAccessor = serviceProvider.GetRequiredService<IHttpContextAccessor>();
return new InAppStorageService(env, httpContextAccessor);
}
else
{
return new AzureStorageService(configuration);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment