SegregatedStorage 1.3.4
See the version list below for details.
dotnet add package SegregatedStorage --version 1.3.4
NuGet\Install-Package SegregatedStorage -Version 1.3.4
<PackageReference Include="SegregatedStorage" Version="1.3.4" />
paket add SegregatedStorage --version 1.3.4
#r "nuget: SegregatedStorage, 1.3.4"
// Install SegregatedStorage as a Cake Addin #addin nuget:?package=SegregatedStorage&version=1.3.4 // Install SegregatedStorage as a Cake Tool #tool nuget:?package=SegregatedStorage&version=1.3.4
SegregatedStorage
A small library for providing segregated storage abstraction for Web API's and similar projects.
Comes with built-in In-Memory support for ease of testing, as well as packages for Azure Blob storage for the actual files and MongoDB for metadata.
Installation
I recommend using the NuGet package: SegregatedStorage however feel free to clone the source instead if that suits your needs better.
For Azure Blob storage support, add this NuGet package: SegregatedStorage.AzureStorageProvider For Mongo File repository support, add this NuGet package: SegregatedStorage.MongoFileRepository
Usage
First inject the core functionality via Dependency Injection.
The type of key (here it's int
), as well as the naming of collection, databases and containers can be whatever you prefer.
builder.Services.AddMongoFileRepository<int>("connectionString", "files", key => $"db-{key}");
builder.Services.AddAzureStorageProvider<int>("connectionString", key => $"container-{key}");
builder.Services.AddStorageService<int>();
Secondly, if you want to utilize the built-in API endpoints, add those to your app:
var app = builder.Build();
app.MapStorageApi(); // This has an optional configuration you can adjust if need be, e.g. for AntiForgery needs
With all this done you can both inject the IStorageService<TKey>
and use it directly, as well as simply use the built-in API endpoints:
- GET /file/{key}/{id}
- DELETE /file/{key}/{id}
- POST /file/{key}
Compatibility
Currently Azure Blob storage is supported for cloud storage of files, and MongoDB is supported as metadata container. Both are configured with a key, to allow for easy segregation of data e.g. between different customers.
Feel free to submit a PR if you add a provider/repository you want to share with everyone else.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net8.0
- Microsoft.AspNetCore.OpenApi (>= 8.0.7)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.1)
- Microsoft.Extensions.Hosting.Abstractions (>= 8.0.0)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on SegregatedStorage:
Package | Downloads |
---|---|
SegregatedStorage.MongoFileRepository
Extension to SegregatedStorage adding support for MongoDB for storing metadata |
|
SegregatedStorage.AzureStorageProvider
Extension to SegregatedStorage adding support for Azure Blob storage |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.4.2 | 3,075 | 11/3/2024 |
1.4.1 | 84 | 11/1/2024 |
1.4.0 | 306 | 10/31/2024 |
1.3.6 | 92 | 10/21/2024 |
1.3.5 | 4,239 | 9/25/2024 |
1.3.4 | 5,812 | 7/29/2024 |
1.3.3 | 9,094 | 3/8/2024 |
1.3.2 | 968 | 3/7/2024 |
1.3.1 | 206 | 3/4/2024 |
1.3.0 | 180 | 3/1/2024 |
1.2.0 | 152 | 2/29/2024 |
1.1.0 | 146 | 2/26/2024 |
1.0.1 | 136 | 2/25/2024 |
1.0.0 | 134 | 2/25/2024 |