Katalyst.App.Storage
1.2.1
dotnet add package Katalyst.App.Storage --version 1.2.1
NuGet\Install-Package Katalyst.App.Storage -Version 1.2.1
<PackageReference Include="Katalyst.App.Storage" Version="1.2.1" />
<PackageVersion Include="Katalyst.App.Storage" Version="1.2.1" />
<PackageReference Include="Katalyst.App.Storage" />
paket add Katalyst.App.Storage --version 1.2.1
#r "nuget: Katalyst.App.Storage, 1.2.1"
#:package Katalyst.App.Storage@1.2.1
#addin nuget:?package=Katalyst.App.Storage&version=1.2.1
#tool nuget:?package=Katalyst.App.Storage&version=1.2.1
App.Storage
Vendor-agnostic object storage for .NET: upload, open, delete, and existence checks via IFileStorage, with built-in Amazon S3 and Azure Blob Storage providers. Streams are used end-to-end (from a web app, pass IFormFile.OpenReadStream() when uploading).
This project is not referenced by the rest of the WebTemplate by default; add a PackageReference to Katalyst.App.Storage or a ProjectReference when you adopt it.
Packages
- AWSSDK.S3 — S3 API; credentials follow the AWS SDK default chain.
- Azure.Storage.Blobs — Blob service.
Microsoft.Extensions.*— options and DI.
Registration
Use AddAppStorage and pick one of UseAmazonS3, UseAzureBlob, or UseCustom. The configuration section names below match AppStorageOptions.SectionName ("Storage") plus a provider key.
using App.Storage.DependencyInjection;
builder.Services.AddAppStorage(builder.Configuration, storage =>
{
storage.UseAmazonS3(builder.Configuration.GetSection("Storage:AmazonS3"));
// or: storage.UseAzureBlob(builder.Configuration.GetSection("Storage:AzureBlob"));
});
Inject IFileStorage where you need to read or write objects.
Example appsettings.json (Amazon S3)
{
"Storage": {
"AmazonS3": {
"BucketName": "my-app-uploads",
"Prefix": "uploads",
"Region": "us-east-1"
}
}
}
Region is optional (defaults to us-east-1). Prefix is optional and prepended to every object key.
Example appsettings.json (Azure Blob)
{
"Storage": {
"AzureBlob": {
"ConnectionString": "UseDevelopmentStorage=true;",
"ContainerName": "uploads",
"Prefix": "files"
}
}
}
Ensure the container exists (or create it out of band); the library does not create the container automatically.
Usage
using App.Storage.Contracts;
public class MyService(IFileStorage files)
{
public async Task SaveAsync(string key, Stream content, CancellationToken ct)
{
await files.UploadAsync(key, content, contentType: "application/pdf", ct);
}
public async Task<Stream> LoadAsync(string key, CancellationToken ct)
{
return await files.OpenReadAsync(key, ct); // dispose the stream when done
}
public Task DeleteAsync(string key, CancellationToken ct) => files.DeleteAsync(key, ct);
public Task<bool> ExistsAsync(string key, CancellationToken ct) => files.ExistsAsync(key, ct);
}
Custom provider
Implement IFileStorage and register:
services.AddAppStorage(configuration, storage => storage.UseCustom<MyFileStorage>());
| 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.6)
- Azure.Storage.Blobs (>= 12.26.0)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.5)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.5)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.5)
- Microsoft.Extensions.Options (>= 10.0.5)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.5)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.