Feature: Google Cloud Storage Provider (ManagedCode.Storage.Gcp)
Purpose
Implement IStorage on top of Google Cloud Storage (GCS) using Google.Cloud.Storage.V1.
Main Flows
flowchart LR
App --> GCS[GCPStorage : IGCPStorage]
GCS --> SDK[Google.Cloud.Storage.V1 StorageClient]
SDK --> Cloud[(GCS)]
Components
Storages/ManagedCode.Storage.Google/GCPStorage.csStorages/ManagedCode.Storage.Google/GCPStorageProvider.cs- DI:
- Options:
DI Wiring
dotnet add package ManagedCode.Storage.Gcp
using Google.Apis.Auth.OAuth2;
using ManagedCode.Storage.Google.Extensions;
using ManagedCode.Storage.Google.Options;
builder.Services.AddGCPStorageAsDefault(options =>
{
options.GoogleCredential = GoogleCredential.FromFile("service-account.json");
options.BucketOptions = new BucketOptions
{
ProjectId = "my-project-id",
Bucket = "my-bucket"
};
});
Current Behavior
- Supports file-based auth (
AuthFileName) and directGoogleCredential. - Bucket creation can be enabled via
CreateContainerIfNotExists.
Tests
Tests/ManagedCode.Storage.Tests/Storages/GCS/GCSUploadTests.csTests/ManagedCode.Storage.Tests/Storages/GCS/GCSDownloadTests.csTests/ManagedCode.Storage.Tests/Storages/GCS/GCSBlobTests.csTests/ManagedCode.Storage.Tests/Storages/GCS/GCSContainerTests.csTests/ManagedCode.Storage.Tests/Storages/GCS/GCSConfigTests.cs