Simple .Net file storage
Install-Package FileStore
Install-Package FileStore.Persistance.EntityFramework
Install-Package FileStore.Persistance.FileSystem
- store files
- load files from store
- controll files versions
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>();
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 :)