Skip to content
File Storage Services for .NET
C# Other
  1. C# 98.5%
  2. Other 1.5%
Branch: master
Clone or download
Latest commit d40c460 Jun 16, 2017

README.md

Cabinet

Build status Coverage Status

Cabinet provides abstractions over various file storage providers. This allows you to develop IO code without having to worry about where the file is actually stored.

Plugging in a new provider is easy as:

cabinetFactory.RegisterFileSystemProvider()

and

IFileCabinet fileCabinet = cabinetFactory.GetCabinet(new FileSystemCabinetConfig() {
    Directory = @"C:\data\"
});

The project has Core packages and Provider packages. Core packages provide abstractions and helpers.

Core Packages Version
Core Cabinet.Core Nuget Version
Config Cabinet.Config Nuget Version
Web Cabinet.Web Nuget Version

We current support the following providers

Provider Provider Package Config Package
File System Cabinet.FileSystem Nuget Version Cabinet.FileSystem.Config Nuget Version
Migrator Cabinet.Migrator Nuget Version Cabinet.Migrator.Config Nuget Version
Amazon S3 Cabinet.S3 Nuget Version Cabinet.S3.Config Nuget Version
Azure Blog TODO TODO
Google Cloud Storage TODO TODO

Getting Started with Cabinet

Cabinet is designed to be very configurable and pluggable.

IFileCabinetFactory cabinetFactory = new FileCabinetFactory(); // or inject IFileCabinetFactory with IOC

cabinetFactory
    .RegisterFileSystemProvider() // Register a file system provider to store files on disk
    .RegisterS3Provider(); // Register an Amazon S3 provider

IFileCabinet fileCabinet = cabinetFactory.GetCabinet(new FileSystemCabinetConfig() {
    Directory = @"C:\data\"
});

IFileCabinet s3Cabinet = cabinetFactory.GetCabinet(new S3CabinetConfig() {
    AWSCredentials = new BasicAWSCredentials("accessKey", "secretKey"), 
    AmazonS3Config = new AmazonS3Config(),
    BucketName = "test-bucket"
});

string fileKey = "foo/bar.txt";

using (var stream = await s3Cabinet.OpenReadStreamAsync(fileKey)) { // open stream for file in s3
    ISaveResult saveResult = await fileCabinet.SaveFileAsync(fileKey, stream, HandleExistingMethod.Overwrite); // save file to disk
}

Questions or Problems?

Open an issue

Contributions

Yes please. Please open an issue before before sending a pull requests. All changes need to be discussed before they are accepted.

License

MIT

You can’t perform that action at this time.