Skip to content

About

No description, website, or topics provided.

Resources

Code of conduct

Contributing

Stars

1 star

Watchers

1 watching

Forks

Repository files navigation

Want to see what's changed?

Changelog

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 Cosmos File repository support, add this NuGet package: SegregatedStorage.CosmosFileRepository 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.AddCosmosFileRepository<int>("connectionString", "files", key => $"db-{key}");
// OR
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 the SegregatedStorage.AspNetCore package to your project as well as these lines:

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.

You can however quite easily build your own IStorageProvider<TKey> or IFileRepository<TKey> if you want to use different technologies.

Feel free to submit a PR if you add a provider/repository you want to share with everyone else.

Documentation

Auto generated documentation via DocFx is available here: https://steffenskov.github.io/SegregatedStorage/

About

No description, website, or topics provided.

Resources

Code of conduct

Contributing

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages