Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

visualeyes/cabinet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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