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
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Katalyst.Core.FileStorage" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Katalyst.Core.FileStorage" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Katalyst.Core.FileStorage" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Katalyst.Core.FileStorage --version 1.0.0
                    
#r "nuget: Katalyst.Core.FileStorage, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Katalyst.Core.FileStorage@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Katalyst.Core.FileStorage&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Katalyst.Core.FileStorage&version=1.0.0
                    
Install as a Cake Tool

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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