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?否—对象名前缀
AuthenticationModeenum否ServiceAccountJwt认证模式
Accessenum否ReadOnly访问级别
TimeoutTimeSpan?否—请求超时
PageSizeint否常量默认值列举分页大小
ResumableUploadChunkSizeint否常量默认值可恢复上传分块大小
ApiRootUri?否—自定义 API 网关(需同时配置 UploadApiRoot + OAuthTokenEndpoint)
UploadApiRootUri?否—自定义上传端点
OAuthTokenEndpointUri?否—自定义 OAuth 令牌端点
TrustedEndpointHostsstring[]否空信任的自定义端点主机
AllowInsecureLoopbackbool否false允许不安全回环地址

配置示例

{
"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 时必须同时配置 UploadApiRoot 和 OAuthTokenEndpoint,否则校验失败。全留空时使用 Google 官方端点。
  • 凭据解析走 IIntegrationCredentialResolver,不通过 Options 直接配置。

相关

100%

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