Skip to content

Files

Latest commit

99d6a98 · May 23, 2024

History

History

FileSystem.Adapters.GoogleDrive

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Jan 2, 2024
May 23, 2024
Feb 12, 2024

SharpGrip FileSystem GoogleDrive adapter NuGet

Installation

Reference NuGet package SharpGrip.FileSystem.Adapters.GoogleDrive (https://www.nuget.org/packages/SharpGrip.FileSystem.Adapters.GoogleDrive).

Usage

// Google connection.
await using var stream = new FileStream("path/to/credentials.json", FileMode.Open, FileAccess.Read);
const string tokenPath = "path/to/token/directory";
var credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(
    (await GoogleClientSecrets.FromStreamAsync(stream)).Secrets,
    new[] {DriveService.Scope.Drive},
    "user",
    CancellationToken.None,
    new FileDataStore(tokenPath, true));

var googleDriveClient = new DriveService(new BaseClientService.Initializer
{
    HttpClientInitializer = credential,
    ApplicationName = "Test"
});

var adapters = new List<IAdapter>
{
    new LocalAdapter("local", "/var/files"),
    new GoogleDriveAdapter("google-drive", "/Files", googleDriveClient)
};

var fileSystem = new FileSystem(adapters);