11# SharpGrip FileSystem [ ![ NuGet] ( https://img.shields.io/nuget/v/SharpGrip.FileSystem )] ( https://www.nuget.org/packages/SharpGrip.FileSystem )
22
33## Builds
4+
45[ ![ FileSystem [ Build]] ( https://github.com/SharpGrip/FileSystem/actions/workflows/Build.yaml/badge.svg )] ( https://github.com/SharpGrip/FileSystem/actions/workflows/Build.yaml )
56
67[ ![ Quality Gate Status] ( https://sonarcloud.io/api/project_badges/measure?project=SharpGrip_FileSystem&metric=alert_status )] ( https://sonarcloud.io/summary/overall?id=SharpGrip_FileSystem ) \
1011[ ![ Coverage] ( https://sonarcloud.io/api/project_badges/measure?project=SharpGrip_FileSystem&metric=coverage )] ( https://sonarcloud.io/summary/overall?id=SharpGrip_FileSystem )
1112
1213## Introduction
14+
1315SharpGrip FileSystem is a file system abstraction supporting multiple adapters.
1416
1517## Installation
18+
1619Reference NuGet package ` SharpGrip.FileSystem ` (https://www.nuget.org/packages/SharpGrip.FileSystem ).
1720
1821For adapters other than the local file system (included in the ` SharpGrip.FileSystem ` package) please see the [ Supported adapters] ( #supported-adapters ) section.
1922
2023## Supported adapters
24+
2125| Adapter | Package | NuGet |
2226| :------------------------------------------------| :--------------------------------------------------| :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
2327| [ Local adapter] ( #local-adapter ) | ` SharpGrip.FileSystem ` | [ ![ NuGet] ( https://img.shields.io/nuget/v/SharpGrip.FileSystem )] ( https://www.nuget.org/packages/SharpGrip.FileSystem ) |
2428| [ AmazonS3] ( #amazons3-adapter ) | ` SharpGrip.FileSystem.Adapters.AmazonS3 ` | [ ![ NuGet] ( https://img.shields.io/nuget/v/SharpGrip.FileSystem.Adapters.AmazonS3 )] ( https://www.nuget.org/packages/SharpGrip.FileSystem.Adapters.AmazonS3 ) |
2529| [ AzureBlobStorage] ( #azureblobstorage-adapter ) | ` SharpGrip.FileSystem.Adapters.AzureBlobStorage ` | [ ![ NuGet] ( https://img.shields.io/nuget/v/SharpGrip.FileSystem.Adapters.AzureBlobStorage )] ( https://www.nuget.org/packages/SharpGrip.FileSystem.Adapters.AzureBlobStorage ) |
2630| [ AzureFileStorage] ( #azurefilestorage-adapter ) | ` SharpGrip.FileSystem.Adapters.AzureFileStorage ` | [ ![ NuGet] ( https://img.shields.io/nuget/v/SharpGrip.FileSystem.Adapters.AzureFileStorage )] ( https://www.nuget.org/packages/SharpGrip.FileSystem.Adapters.AzureFileStorage ) |
2731| [ Dropbox] ( #dropbox-adapter ) | ` SharpGrip.FileSystem.Adapters.Dropbox ` | [ ![ NuGet] ( https://img.shields.io/nuget/v/SharpGrip.FileSystem.Adapters.Dropbox )] ( https://www.nuget.org/packages/SharpGrip.FileSystem.Adapters.Dropbox ) |
32+ | [ GoogleDrive] ( #googledrive-adapter ) | ` SharpGrip.FileSystem.Adapters.GoogleDrive ` | [ ![ NuGet] ( https://img.shields.io/nuget/v/SharpGrip.FileSystem.Adapters.GoogleDrive )] ( https://www.nuget.org/packages/SharpGrip.FileSystem.Adapters.GoogleDrive ) |
2833| [ MicrosoftOneDrive] ( #microsoftonedrive-adapter ) | ` SharpGrip.FileSystem.Adapters.MicrosoftOneDrive ` | [ ![ NuGet] ( https://img.shields.io/nuget/v/SharpGrip.FileSystem.Adapters.MicrosoftOneDrive )] ( https://www.nuget.org/packages/SharpGrip.FileSystem.Adapters.MicrosoftOneDrive ) |
2934| [ SFTP] ( #sftp-adapter ) | ` SharpGrip.FileSystem.Adapters.Sftp ` | [ ![ NuGet] ( https://img.shields.io/nuget/v/SharpGrip.FileSystem.Adapters.Sftp )] ( https://www.nuget.org/packages/SharpGrip.FileSystem.Adapters.Sftp ) |
3035
3136## Supported operations
37+
3238For a full list of the supported operations please see the [ IFileSystem] ( ../master/FileSystem/src/IFileSystem.cs ) interface.
3339
3440## Usage
3541
3642### Instantiation
43+
3744```
3845var adapters = new List<IAdapter>
3946{
@@ -49,6 +56,7 @@ fileSystem.Adapters = adapters;
4956```
5057
5158### Local adapter
59+
5260```
5361var adapters = new List<IAdapter>
5462{
@@ -60,6 +68,7 @@ var fileSystem = new FileSystem(adapters);
6068```
6169
6270### AmazonS3 adapter
71+
6372```
6473// Amazon connection.
6574var amazonClient = new AmazonS3Client("awsAccessKeyId", "awsSecretAccessKey", RegionEndpoint.USEast2);
@@ -74,6 +83,7 @@ var fileSystem = new FileSystem(adapters);
7483```
7584
7685### AzureBlobStorage adapter
86+
7787```
7888// Azure connection.
7989var blobServiceClient = new BlobServiceClient("connectionString");
@@ -89,6 +99,7 @@ var fileSystem = new FileSystem(adapters);
8999```
90100
91101### AzureFileStorage adapter
102+
92103```
93104// Azure connection.
94105var azureClient = new ShareClient("connectionString", "shareName");
@@ -103,6 +114,7 @@ var fileSystem = new FileSystem(adapters);
103114```
104115
105116### Dropbox adapter
117+
106118```
107119// Dropbox connection.
108120var dropboxClient = new DropboxClient("oAuth2AccessToken");
@@ -116,7 +128,36 @@ var adapters = new List<IAdapter>
116128var fileSystem = new FileSystem(adapters);
117129```
118130
131+ ### GoogleDrive adapter
132+
133+ ```
134+ // Google connection.
135+ await using var stream = new FileStream("path/to/credentials.json", FileMode.Open, FileAccess.Read);
136+ const string tokenPath = "path/to/token/directory";
137+ var credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(
138+ (await GoogleClientSecrets.FromStreamAsync(stream)).Secrets,
139+ new[] {DriveService.Scope.Drive},
140+ "user",
141+ CancellationToken.None,
142+ new FileDataStore(tokenPath, true));
143+
144+ var googleDriveClient = new DriveService(new BaseClientService.Initializer
145+ {
146+ HttpClientInitializer = credential,
147+ ApplicationName = "Test"
148+ });
149+
150+ var adapters = new List<IAdapter>
151+ {
152+ new LocalAdapter("local", "/var/files"),
153+ new GoogleDriveAdapter("google-drive", "/Files", googleDriveClient)
154+ };
155+
156+ var fileSystem = new FileSystem(adapters);
157+ ```
158+
119159### MicrosoftOneDrive adapter
160+
120161```
121162// Microsoft connection.
122163var scopes = new[] {"https://graph.microsoft.com/.default"};
@@ -143,6 +184,7 @@ var fileSystem = new FileSystem(adapters);
143184```
144185
145186### SFTP adapter
187+
146188```
147189// SFTP connection.
148190var privateKeyFile = new PrivateKeyFile("/home/userName/.ssh/id_rsa");
@@ -160,6 +202,7 @@ var fileSystem = new FileSystem(adapters);
160202```
161203
162204### Example operations
205+
163206```
164207// Azure connection.
165208var azureClient = new ShareClient("connectionString", "shareName");
0 commit comments