Skip to content
No description, website, or topics provided.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
.gitattributes
.gitignore
LICENSE.md
README.md

README.md

FileStore

Simple .Net file storage

NuGet

Install-Package FileStore
Install-Package FileStore.Persistance.EntityFramework
Install-Package FileStore.Persistance.FileSystem

Features

  • store files
  • load files from store
  • controll files versions

Usages

Versioned file store:

var fileStoreBuilder = FileStoreBuilder.Config(cfg =>
{
    cfg.UseFileSystem("myDirectory\\fileStoreDirectory");
});
var store = fileStoreBuilder.BuildVersioned();

var id = Guid.NewGuid();
store.StoreFile(id, new StoreFile { Data = new byte[] { 1, 2, 3 }, Extension = "txt" });
store.StoreFile(id, new StoreFile { Data = new byte[] { 1, 2, 3, 4, 5, 6 }, Extension = "txt" });

var latestFileVersion = store.OpenFile(id);
var firstVersion = store.OpenFile(id, 0);

Unversioned file store:

var store = fileStoreBuilder.BuildUnversioned();

With this setup You saves and opens files at single version - there is no store.OpenFile(Guid, int)

Using Entity Framework:

var fileStoreBuilder = FileStoreBuilder.Config(cfg =>
{
  cfg.UseEntityFramework("some.connection.string.name");
  cfg.InitializeDatabase();
});

Registering in some container (Autofac in this example):

var containerBuilder = new ContainerBuilder();
var fileStoreBuilder = FileStoreBuilder.Config(cfg =>
{
    cfg.UseFileSystem("C:\\fileStore");
});

containerBuilder.Register(c => fileStoreBuilder.BuildVersioned());

var container = containerBuilder.Build();
var store = container.Resolve<IFileStore>();

Contribute

Creating new Persistance engine is very simple - just implement IPersistance and provide configuration extensions.

Maybe You have other idea - do no hesitate - please send me some pull request :)

You can’t perform that action at this time.