tencent_cos_dart 0.1.2
tencent_cos_dart: ^0.1.2 copied to clipboard
Tencent Cloud COS presigned URL signing for Dart.
tencent_cos_dart #
Tencent Cloud COS presigned URL signer (pure Dart). Tencent Cloud COS 预签名 URL 生成器(纯 Dart)。
Features / 功能 #
- Generate COS presigned URLs (GET/PUT/DELETE/POST)
- Custom domain support (with or without scheme)
- 生成 COS 预签名 URL(GET/PUT/DELETE/POST)
- 支持自定义域名(支持带协议或仅 Host)
Install / 安装 #
dependencies:
tencent_cos_dart: ^0.1.0
China mirror (optional) / 中国镜像(可选) #
Ref / 参考: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"
Usage / 使用 #
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', // optional / 可选
);
final signer = CosSigner.fromConfig(config);
final url = signer.generatePresignedUrl(
'PUT',
'src/public/example/file.png',
expires: 3600,
);
Where to find COS settings / 参数来源(腾讯云控制台) #
1) SecretId / SecretKey #
- API Key Management / API 密钥管理:
https://console.cloud.tencent.com/cam/capi
2) Bucket #
- COS Console / COS 控制台:
https://console.cloud.tencent.com/cos5 - Doc / 文档:
https://cloud.tencent.com/document/product/436/13309
3) Region #
- Doc / 文档:
https://cloud.tencent.com/document/product/436/6224
4) customDomain (optional) #
- Doc / 文档:
https://cloud.tencent.com/document/product/436/18424
Notes / 注意 #
objectKeycan bepath/to/fileor/path/to/file.customDomaincan behttps://example.comorexample.com.objectKey可写成path/to/file或/path/to/file。customDomain可以是https://example.com或example.com。
Maintenance / 维护 #
- Versioning: SemVer
- Feedback: issue / PR