ValiBlob.GCP
1.0.0
Error en el nombre de paquete.
dotnet add package ValiBlob.GCP --version 1.0.0
NuGet\Install-Package ValiBlob.GCP -Version 1.0.0
<PackageReference Include="ValiBlob.GCP" Version="1.0.0" />
<PackageVersion Include="ValiBlob.GCP" Version="1.0.0" />
<PackageReference Include="ValiBlob.GCP" />
paket add ValiBlob.GCP --version 1.0.0
#r "nuget: ValiBlob.GCP, 1.0.0"
#:package ValiBlob.GCP@1.0.0
#addin nuget:?package=ValiBlob.GCP&version=1.0.0
#tool nuget:?package=ValiBlob.GCP&version=1.0.0
Vali-Blob.GCP
Google Cloud Storage provider for Vali-Blob — the unified cloud storage abstraction library for .NET.
Implements IStorageProvider over GCS with signed URL generation, resumable uploads, Application Default Credentials support, and seamless DI registration.
Compatibility
| Target Framework | Supported |
|---|---|
netstandard2.0 |
Yes |
netstandard2.1 |
Yes |
net6.0 |
Yes |
net7.0 |
Yes |
net8.0 |
Yes |
net9.0 |
Yes |
Installation
dotnet add package ValiBlob.Core
dotnet add package ValiBlob.GCP
Configuration
With a service account credentials file (recommended)
{
"ValiBlob": {
"DefaultProvider": "GCP"
},
"ValiBlob:GCP": {
"Bucket": "my-app-bucket",
"CredentialsPath": "/run/secrets/gcp-service-account.json"
}
}
With credentials JSON inline
{
"ValiBlob:GCP": {
"Bucket": "my-app-bucket",
"CredentialsJson": "{ \"type\": \"service_account\", \"project_id\": \"...\", ... }"
}
}
With Application Default Credentials (ADC)
{
"ValiBlob:GCP": {
"Bucket": "my-app-bucket"
}
}
Note: When using ADC (Compute Engine, Cloud Run, GKE Workload Identity), most operations work out of the box. However, presigned (signed) URLs require a service account key — ADC does not carry the private key needed for V4 signing. Provide
CredentialsPathorCredentialsJsonto enable presigned URLs.
Registration
using ValiBlob.Core.DependencyInjection;
using ValiBlob.GCP.Extensions;
builder.Services
.AddValiBlob(opts => opts.DefaultProvider = "GCP")
.UseGCP();
With pipeline
builder.Services
.AddValiBlob(opts => opts.DefaultProvider = "GCP")
.UseGCP()
.WithPipeline(p => p
.UseValidation(v =>
{
v.AllowedExtensions = new[] { ".jpg", ".png", ".mp4", ".pdf" };
v.MaxFileSizeBytes = 500 * 1024 * 1024; // 500 MB
})
);
Usage
Upload
public class MediaService(IStorageProvider storage)
{
public async Task<string> UploadAsync(Stream content, string fileName, string contentType)
{
var result = await storage.UploadAsync(new UploadRequest
{
Path = StoragePath.From("media", fileName),
Content = content,
ContentType = contentType
});
if (!result.IsSuccess)
throw new Exception(result.ErrorMessage);
return result.Value!.Url;
}
}
Download
var result = await storage.DownloadAsync(new DownloadRequest
{
Path = StoragePath.From("media", "photo.jpg")
});
if (result.IsSuccess)
await result.Value!.CopyToAsync(outputStream);
Signed URL (requires service account)
// Presigned download URL — valid for 2 hours
var url = await storage.GetPresignedDownloadUrlAsync(new PresignedUrlRequest
{
Path = StoragePath.From("reports", "annual-2024.pdf"),
ExpiresIn = TimeSpan.FromHours(2)
});
if (url.IsSuccess)
return Redirect(url.Value!);
else
return BadRequest(url.ErrorMessage); // "NotSupported" if ADC is used
Resumable upload
var session = await resumable.StartUploadAsync(new ResumableUploadRequest
{
FileName = "dataset.zip",
ContentType = "application/zip",
TotalSize = totalBytes
});
await resumable.UploadChunkAsync(new ResumableChunkRequest
{
SessionId = session.SessionId,
ChunkIndex = 0,
Data = chunkStream
});
await resumable.CompleteUploadAsync(session.SessionId);
Features
| Feature | Supported |
|---|---|
| Upload / Download / Delete / List | Yes |
| Exists check | Yes |
| Copy / Move | Yes |
| Signed upload URL | Yes (service account required) |
| Signed download URL | Yes (service account required) |
| Resumable chunked uploads | Yes |
| BucketOverride per request | Yes |
| Application Default Credentials | Yes |
| Custom metadata | Yes |
| Polly retry resilience | Yes |
Options reference
| Property | Default | Description |
|---|---|---|
Bucket |
— | GCS bucket name (required) |
CredentialsPath |
— | Path to service account JSON key file |
CredentialsJson |
— | Service account JSON content as a string |
SignedUrlExpiryMinutes |
60 |
Default expiry for generated signed URLs |
Documentation
Links
Donations
If Vali-Blob is useful to you, consider supporting its development:
- Latin America — MercadoPago
- International — PayPal
License
Contributions
Issues and pull requests are welcome on GitHub.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. 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 was computed. 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. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Google.Cloud.Storage.V1 (>= 4.10.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 9.0.0)
- ValiBlob.Core (>= 1.0.0)
-
.NETStandard 2.1
- Google.Cloud.Storage.V1 (>= 4.10.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 9.0.0)
- ValiBlob.Core (>= 1.0.0)
-
net6.0
- Google.Cloud.Storage.V1 (>= 4.10.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 9.0.0)
- ValiBlob.Core (>= 1.0.0)
-
net7.0
- Google.Cloud.Storage.V1 (>= 4.10.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 9.0.0)
- ValiBlob.Core (>= 1.0.0)
-
net8.0
- Google.Cloud.Storage.V1 (>= 4.10.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 9.0.0)
- ValiBlob.Core (>= 1.0.0)
-
net9.0
- Google.Cloud.Storage.V1 (>= 4.10.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 9.0.0)
- ValiBlob.Core (>= 1.0.0)
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 |
|---|
See CHANGELOG.md at https://github.com/UBF21/Vali-Blob/blob/main/CHANGELOG.md