Skip to content

mgibas/FileStore

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 :)

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages