BeeQ.FileStorage.GoogleDrive
1.0.0
dotnet add package BeeQ.FileStorage.GoogleDrive --version 1.0.0
NuGet\Install-Package BeeQ.FileStorage.GoogleDrive -Version 1.0.0
<PackageReference Include="BeeQ.FileStorage.GoogleDrive" Version="1.0.0" />
<PackageVersion Include="BeeQ.FileStorage.GoogleDrive" Version="1.0.0" />
<PackageReference Include="BeeQ.FileStorage.GoogleDrive" />
paket add BeeQ.FileStorage.GoogleDrive --version 1.0.0
#r "nuget: BeeQ.FileStorage.GoogleDrive, 1.0.0"
#:package BeeQ.FileStorage.GoogleDrive@1.0.0
#addin nuget:?package=BeeQ.FileStorage.GoogleDrive&version=1.0.0
#tool nuget:?package=BeeQ.FileStorage.GoogleDrive&version=1.0.0
BeeQ.FileStorage.GoogleDrive
BeeQ.FileStorage.GoogleDrive is a lightweight Google Drive provider for the BeeQ file storage abstraction.
This library integrates Google Drive as a file storage backend and exposes Drive-specific operations in addition to the generic file storage contract. It is intended to be published as a NuGet package and consumed by applications that need to store, list and share files on Google Drive using a simple, testable API.
Supported target frameworks: .NET 6+ (library is compatible with modern .NET versions).
Features
- Configure Google Drive OAuth2 client credentials and token storage.
- Upload and download file streams through the BeeQ file storage abstraction.
- Create folders and ensure folder paths exist.
- List files inside a folder.
- Copy and move files between folders.
- Get download links and make files public.
- Trash (soft-delete) files.
Prerequisites
- Enable the Google Drive API in the Google Cloud Console for your project.
- Create OAuth2 client credentials and obtain the client id / client secret (or a client secrets JSON).
Installation
Install the NuGet package (replace the package id with the released package name if different):
dotnet add package BeeQ.FileStorage.GoogleDrive
Quick start
- Configure credentials and options
using Google.Apis.Auth.OAuth2;
using BeeQ.FileStorage.GoogleDrive;
var options = new GoogleDriveConfiguration
{
ClientSecrets = new ClientSecrets
{
ClientId = "YOUR_CLIENT_ID",
ClientSecret = "YOUR_CLIENT_SECRET",
},
ApplicationName = "MyApp",
// Either set a BasePath or provide a PathTemplate function used to compute the full path for files
BasePath = "my-app-files"
};
- Register or create the service
The package exposes an extension method UseGoogleDrive for the BeeQ file storage builder. Example usage depends on your application setup. The example below shows the typical pattern when using the file storage builder API:
// 'builder' is an instance of IFileStorageBuilder from the BeeQ file storage package
var googleService = builder.UseGoogleDrive(cfg => {
cfg.ClientSecrets = new ClientSecrets { ClientId = "...", ClientSecret = "..." };
cfg.BasePath = "my-app-files";
cfg.ApplicationName = "MyApp";
});
// googleService implements IGoogleDriveService
If you use your own dependency injection container you should obtain the IGoogleDriveService from the container after it has been registered by the builder.
Examples
Create a folder
var folder = await googleService.CreateFolderAsync("invoices", "root");
Console.WriteLine($"Created folder: {folder.Id} ({folder.Name})");
List files in a folder
var files = await googleService.ListFolderFilesAsync(folder.Id);
foreach (var f in files)
Console.WriteLine($"{f.Id} {f.Name} ({f.MimeType})");
Copy a file to another folder (optionally rename)
var copied = await googleService.CopyFileAsync(sourceFileId: "abc123", destinationFolderId: folder.Id, destinationName: "copy-of-report.pdf");
Console.WriteLine($"Copied file id: {copied.Id}");
Move a file between folders
var moved = await googleService.MoveFileAsync(fileId: "abc123", destinationFolderId: folder.Id);
Console.WriteLine($"Moved file id: {moved.Id} new parents: {string.Join(',', moved.Parents ?? Enumerable.Empty<string>())}");
Get a download link and make a file public
var link = await googleService.GetDownloadLinkAsync(fileId: "abc123");
if (link != null)
Console.WriteLine($"Download link: {link}");
await googleService.MakeFilePublicAsync("abc123");
Trash (soft-delete) a file
await googleService.Trash("abc123");
Uploading and downloading streams
This package integrates with the BeeQ file storage abstraction (IFileStorage<TIdentifier>). The concrete upload/download method names depend on the abstraction used in your application. In general you'll call the file storage upload method (for example, an UploadStream or similar) and the provider will store the content in Google Drive. Use the extension methods above to access Drive-specific API when needed.
Notes and guidance
- The library uses OAuth2: when running for the first time a browser-based consent flow may be required to grant access to the Google account used by the ClientSecrets.
- By default the package stores credentials using the IDataStore configured in GoogleDriveConfiguration.CustomDataStore. If you do not provide a custom IDataStore, an in-memory implementation is used (not durable across process restarts).
- Ensure the Drive API scopes you need are enabled; the implementation uses DriveFile scope by default.
Contributing and License
See the repository for contributing guidelines and the LICENSE file for license terms.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- BeeQ.FileStorage (>= 1.4.0)
- Google.Apis.Drive.v3 (>= 1.76.0.4252)
-
net6.0
- BeeQ.FileStorage (>= 1.4.0)
- Google.Apis.Drive.v3 (>= 1.76.0.4252)
-
net7.0
- BeeQ.FileStorage (>= 1.4.0)
- Google.Apis.Drive.v3 (>= 1.76.0.4252)
-
net8.0
- BeeQ.FileStorage (>= 1.4.0)
- Google.Apis.Drive.v3 (>= 1.76.0.4252)
-
net9.0
- BeeQ.FileStorage (>= 1.4.0)
- Google.Apis.Drive.v3 (>= 1.76.0.4252)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 55 | 9/8/2026 |