Katalyst.Core.FileStorage
1.0.0
dotnet add package Katalyst.Core.FileStorage --version 1.0.0
NuGet\Install-Package Katalyst.Core.FileStorage -Version 1.0.0
<PackageReference Include="Katalyst.Core.FileStorage" Version="1.0.0" />
<PackageVersion Include="Katalyst.Core.FileStorage" Version="1.0.0" />
<PackageReference Include="Katalyst.Core.FileStorage" />
paket add Katalyst.Core.FileStorage --version 1.0.0
#r "nuget: Katalyst.Core.FileStorage, 1.0.0"
#:package Katalyst.Core.FileStorage@1.0.0
#addin nuget:?package=Katalyst.Core.FileStorage&version=1.0.0
#tool nuget:?package=Katalyst.Core.FileStorage&version=1.0.0
Core.FileStorage
Small abstraction over blob/object storage with dependency injection: local filesystem, Amazon S3, or Azure Blob Storage. The active backend is chosen from configuration (Storage:Provider).
Installation
Reference this project (or package) from your application and ensure configuration is available (IConfiguration). For S3, configure AWS credentials using the AWS SDK default credential chain. For Azure, supply a storage connection string.
Transitive packages include AWSSDK.S3 and Azure.Storage.Blobs; unused providers still ship with those dependencies today.
Configuration (appsettings.json)
All providers share a root section Storage. Set Storage:Provider to one of:
Provider value |
Configuration subsection used |
|---|---|
Local |
Storage:Local |
S3 |
Storage:AmazonS3 |
Azure |
Storage:AzureBlob |
Names are compared case-insensitively.
Example: Local filesystem
{
"Storage": {
"Provider": "Local",
"Local": {
"RootPath": "C:\\app-data\\blobs",
"Prefix": ""
}
}
}
| Key | Required | Description |
|---|---|---|
RootPath |
Yes | Root directory for stored files. Absolute: used as given (normalized). Relative: resolved by walking up from AppContext.BaseDirectory until a directory containing an SDK project file (*.csproj, *.vbproj, *.fsproj) is found; the relative path is then combined with that directory (so "storage" typically becomes ...\YourApp\storage\ next to your .csproj during dotnet run). If no project file is found (common when published), the anchor falls back to AppContext.BaseDirectory. |
Prefix |
No | Optional prefix applied to every logical key (like a folder). |
For paths that must not follow this heuristic (for example ASP.NET content root instead of the project folder), set RootPath to an absolute path you compute at startup (e.g. Path.Combine(builder.Environment.ContentRootPath, "App_Data", "files")).
Example: Amazon S3
{
"Storage": {
"Provider": "S3",
"AmazonS3": {
"BucketName": "my-app-bucket",
"Region": "us-east-1",
"Prefix": "uploads"
}
}
}
| Key | Required | Description |
|---|---|---|
BucketName |
Yes | S3 bucket name. |
Region |
No | AWS region system name (e.g. us-east-1). If omitted or empty, defaults to us-east-1. |
Prefix |
No | Optional object key prefix. |
Example: Azure Blob Storage
{
"Storage": {
"Provider": "Azure",
"AzureBlob": {
"ConnectionString": "DefaultEndpointsProtocol=https;AccountName=...;AccountKey=...;EndpointSuffix=core.windows.net",
"ContainerName": "my-container",
"Prefix": "uploads"
}
}
}
| Key | Required | Description |
|---|---|---|
ConnectionString |
Yes | Azure Storage connection string. |
ContainerName |
Yes | Blob container name. |
Prefix |
No | Optional blob name prefix (virtual folder). |
You can keep all three subsections in one file and switch Provider between environments.
Registering services
ASP.NET Core minimal hosting
using Core.FileStorage.DependencyInjection;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddAppStorage(builder.Configuration);
var app = builder.Build();
Resolve Core.FileStorage.Contracts.IFileStorage from DI (constructors or minimal APIs).
Console app or generic host (ServiceCollection)
using Core.FileStorage.Contracts;
using Core.FileStorage.DependencyInjection;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
var configuration = new ConfigurationBuilder()
.SetBasePath(AppContext.BaseDirectory)
.AddJsonFile("appsettings.json", optional: false)
.Build();
var services = new ServiceCollection();
services.AddSingleton<IConfiguration>(configuration);
services.AddAppStorage(configuration);
await using ServiceProvider provider = services.BuildServiceProvider();
var storage = provider.GetRequiredService<IFileStorage>();
Using IFileStorage
using Core.FileStorage.Contracts;
// Upload
await using var upload = new MemoryStream(System.Text.Encoding.UTF8.GetBytes("Hello"));
await storage.UploadAsync("documents/hello.txt", upload, contentType: "text/plain", cancellationToken);
// Exists
var exists = await storage.ExistsAsync("documents/hello.txt", cancellationToken);
// Download (dispose the stream when finished)
await using var readStream = await storage.OpenReadAsync("documents/hello.txt", cancellationToken);
// Delete
await storage.DeleteAsync("documents/hello.txt", cancellationToken);
Custom implementation
Register your own type instead of calling AddAppStorage:
services.AddSingleton<IFileStorage, MyCustomFileStorage>();
Constants
Section and provider key names are defined on Core.FileStorage.AppStorageOptions (SectionName = "Storage", ProviderKey = "Provider").
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- AWSSDK.S3 (>= 4.0.23)
- Azure.Storage.Blobs (>= 12.27.0)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.7)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.7)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.7)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.7)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 133 | 5/9/2026 |