FileSystem
SharpGrip FileSystem is a file system abstraction supporting multiple adapters.
SharpGrip FileSystem is a versatile .NET file system abstraction that supports multiple storage adapters. It empowers developers to manage various file systems and services through a unified and easily comprehensible API. By coding against the abstractions provided by this library, developers can sidestep vendor-specific APIs, effectively avoiding vendor lock-ins. This flexibility enhances the portability and maintainability of the codebase, allowing for smoother transitions between different fi... The project is written primarily in C#, distributed under the MIT License license, first published in 2019. Key topics include: amazon-s3, azure-blob-storage, azure-file-storage, csharp, dotnet.
SharpGrip FileSystem 
Builds
Introduction
SharpGrip FileSystem is a versatile .NET file system abstraction that supports multiple storage adapters.
It empowers developers to manage various file systems and services through a unified and easily comprehensible API.
By coding against the abstractions provided by this library, developers can sidestep vendor-specific APIs, effectively avoiding vendor lock-ins.
This flexibility enhances the portability and maintainability of the codebase, allowing for smoother transitions between different file systems.
Installation
Reference NuGet package SharpGrip.FileSystem (https://www.nuget.org/packages/SharpGrip.FileSystem).
For adapters other than the local file system (included in the SharpGrip.FileSystem package) please see the Supported adapters section.
Supported adapters
| Adapter | Package | NuGet |
|---|---|---|
| Local adapter | SharpGrip.FileSystem | |
| AmazonS3 | SharpGrip.FileSystem.Adapters.AmazonS3 | |
| AzureBlobStorage | SharpGrip.FileSystem.Adapters.AzureBlobStorage | |
| AzureFileStorage | SharpGrip.FileSystem.Adapters.AzureFileStorage | |
| Dropbox | SharpGrip.FileSystem.Adapters.Dropbox | |
| FTP | SharpGrip.FileSystem.Adapters.Ftp | |
| GoogleCloudStorage | SharpGrip.FileSystem.Adapters.GoogleCloudStorage | |
| GoogleDrive | SharpGrip.FileSystem.Adapters.GoogleDrive | |
| MicrosoftOneDrive | SharpGrip.FileSystem.Adapters.MicrosoftOneDrive | |
| SFTP | SharpGrip.FileSystem.Adapters.Sftp |
Supported operations
For a full list of the supported operations please see the IFileSystem interface.
Usage
Instantiation
var adapters = new List<IAdapter>
{
new LocalAdapter("adapterPrefix", "adapterRootPath")
};
// Instantiation option 1.
var fileSystem = new FileSystem(adapters);
// Instantiation option 2.
var fileSystem = new FileSystem();
fileSystem.Adapters = adapters;
Local adapter
var adapters = new List<IAdapter>
{
new LocalAdapter("local1", "/var/files"),
new LocalAdapter("local2", "D:\\Files")
};
var fileSystem = new FileSystem(adapters);
Example operations
// Azure connection.
var azureClient = new ShareClient("connectionString", "shareName");
// Dropbox connection.
var dropboxClient = new DropboxClient("oAuth2AccessToken");
var adapters = new List<IAdapter>
{
new LocalAdapter("local", "/var/files"),
new AzureFileStorageAdapter("azure", "/Files", azureClient),
new DropboxAdapter("dropbox", "/Files", dropboxClient)
};
// Copies a file from the `local` adapter to the `azure` adapter.
await fileSystem.CopyFileAsync("local://foo/bar.txt", "azure://bar/foo.txt");
// Moves a file from the `azure` adapter to the `dropbox` adapter.
await fileSystem.MoveFileAsync("azure://Foo/Bar.txt", "dropbox://Bar/Foo.txt");
// Writes string contents to the `azure` adapter.
await fileSystem.WriteFileAsync("azure://Foo.txt", "Bar!");
// Reads a text file from the `dropbox` adapter.
var contents = fileSystem.ReadTextFileAsync("dropbox://Foo.txt");
Contributors
Showing top 2 contributors by commit count.