Git Product home page Git Product logo

segregatedstorage's Introduction

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.

segregatedstorage's People

Contributors

dependabot[bot] avatar steffenskov avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.