Skip to content
Bitzsoft.Integrationsbitzsoft.integrations

Reference

Google Cloud Storage

Google Cloud Storage 文件存储包的 GoogleCloudStorageOptions 配置字段、ServiceAccountJwt 鉴权、凭据解析器与使用示例。

Last updated

包信息

属性
NuGet 包Bitzsoft.Integrations.FileStorage.GoogleCloud
Provider IDgooglecloud
鉴权ServiceAccountJwt(凭据由 IIntegrationCredentialResolver 从 Vault/KMS 解析)

配置字段(GoogleCloudStorageOptions)

字段类型必填默认值说明
BucketNamestring存储桶名称
ObjectPrefixstring?对象名前缀
AuthenticationModeenumServiceAccountJwt认证模式
AccessenumReadOnly访问级别
TimeoutTimeSpan?请求超时
PageSizeint常量默认值列举分页大小
ResumableUploadChunkSizeint常量默认值可恢复上传分块大小
ApiRootUri?自定义 API 网关(需同时配置 UploadApiRoot + OAuthTokenEndpoint)
UploadApiRootUri?自定义上传端点
OAuthTokenEndpointUri?自定义 OAuth 令牌端点
TrustedEndpointHostsstring[]信任的自定义端点主机
AllowInsecureLoopbackboolfalse允许不安全回环地址

配置示例

{
"FileStorage": {
"GoogleCloud": {
"BucketName": "my-bucket",
"ObjectPrefix": "uploads/",
"AuthenticationMode": "ServiceAccountJwt",
"Access": "ReadWrite"
}
}
}

DI 注册

builder.Services.AddBitzsoftGoogleCloudStorageFileStorage(builder.Configuration.GetSection("FileStorage:GoogleCloud"));

使用示例

public class GcsService(IFileStore store)
{
public async Task<Stream?> DownloadAsync(string fileName)
{
return await store.GetFileStreamAsync(fileName);
}
}

已知限制

  • 自定义端点需三件套:配置 ApiRoot 时必须同时配置 UploadApiRootOAuthTokenEndpoint,否则校验失败。全留空时使用 Google 官方端点。
  • 凭据解析走 IIntegrationCredentialResolver,不通过 Options 直接配置。

相关

100%

滚轮或按钮缩放 · 放大后拖动画面 · 双击切换 100% / 200%