tencent_cos_dart 0.1.0 copy "tencent_cos_dart: ^0.1.0" to clipboard
tencent_cos_dart: ^0.1.0 copied to clipboard

Tencent Cloud COS presigned URL signing for Dart.

tencent_cos_dart #

Tencent Cloud COS 预签名 URL 生成器(纯 Dart)。

功能 #

  • 生成 COS 预签名 URL(GET/PUT/DELETE/POST)
  • 支持自定义域名(支持带协议或仅 Host)

安装 #

dependencies:
  tencent_cos_dart: ^0.1.0

在中国网络环境下加速(可选) #

参考:https://docs.flutter.cn/community/china

macOS / Linux(临时生效):

export PUB_HOSTED_URL="https://pub.flutter-io.cn"
export FLUTTER_STORAGE_BASE_URL="https://storage.flutter-io.cn"

Windows PowerShell(临时生效):

$env:PUB_HOSTED_URL="https://pub.flutter-io.cn"
$env:FLUTTER_STORAGE_BASE_URL="https://storage.flutter-io.cn"

使用 #

import 'package:tencent_cos_dart/tencent_cos_dart.dart';

final config = CosConfig(
  secretId: '<TENCENT_SECRET_ID>',
  secretKey: '<TENCENT_SECRET_KEY>',
  bucket: '<COS_BUCKET_NAME>',
  region: '<COS_REGION>',
  customDomain: 'https://my-cdn.example.com', // 可选
);

final signer = CosSigner.fromConfig(config);
final url = signer.generatePresignedUrl(
  'PUT',
  'src/public/example/file.png',
  expires: 3600,
);

这些参数去哪里找(腾讯云控制台) #

1) SecretId / SecretKey #

在“访问管理”的 API 密钥管理里创建/查看:

  • 控制台入口:https://console.cloud.tencent.com/cam/capi

2) Bucket(存储桶名称) #

在 COS 控制台的 存储桶列表里可以看到(bucket 名称通常形如 my-bucket-125xxxxxxxx):

  • 控制台入口:https://console.cloud.tencent.com/cos5
  • 参考文档(创建/概念):https://cloud.tencent.com/document/product/436/13309

3) Region(地域) #

同样在存储桶列表/存储桶概览中查看(例如 ap-guangzhou):

  • 参考文档(地域与访问域名):https://cloud.tencent.com/document/product/436/6224

4) customDomain(可选:自定义域名/加速域名) #

如果你为存储桶配置了自定义域名(CNAME / HTTPS 等),就可以填到 customDomain

  • 参考文档(域名管理概述):https://cloud.tencent.com/document/product/436/18424

注意 #

  • objectKey 可写成 path/to/file/path/to/file,都会被自动规范化。
  • customDomain 可以是 https://example.comexample.com,内部会统一处理。

维护与兼容性 #

  • 版本策略:SemVer
  • 反馈:issue / PR
1
likes
0
points
194
downloads

Publisher

verified publisherdartpub.tijingapp.com

Weekly Downloads

Tencent Cloud COS presigned URL signing for Dart.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

crypto

More

Packages that depend on tencent_cos_dart