包信息
| 属性 | 值 |
|---|---|
| NuGet 包 | Bitzsoft.Integrations.FileStorage.Tencent |
| Provider ID | tencent |
| 鉴权 | AppId + SecretId + SecretKey |
配置字段(TencentCosOptions)
| 字段 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
AppId | string | 是 | — | 腾讯云 AppId |
SecretId | string | 是 | — | 腾讯云 SecretId |
SecretKey | string | 是 | — | 腾讯云 SecretKey |
Region | string | 是 | — | COS 区域(如 ap-guangzhou) |
DefaultBucketName | string | 是 | — | 默认存储桶名称(不含 AppId 后缀) |
HttpClientName | string | 否 | — | HttpClient 名称 |
UploadUrlExpiration | int | 否 | 3600 | 上传地址过期时间(秒) |
DownloadUrlExpiration | int | 否 | 43200 | 下载地址过期时间(秒) |
配置示例
{ "FileStorage": { "Tencent": { "AppId": "1234567890", "SecretId": "AKIDxxxxxxxx", "SecretKey": "your-secret-key", "Region": "ap-guangzhou", "DefaultBucketName": "my-bucket" } }}DI 注册
builder.Services.AddBitzsoftTencentCosFileStorage(builder.Configuration.GetSection("FileStorage:Tencent"));使用示例
public class CosService(IFileStore store){ public async Task<DirectUploadParam> GetUploadUrlAsync(string fileName) { return await store.GenerateUploadUrlAsync(fileName); }}已知限制
DefaultBucketName不含 AppId 后缀(腾讯桶名格式为bucket-name-AppId,实现自动拼接)。- 下载地址过期时间默认 43200 秒(12 小时),比上传的 1 小时长。