Tencent.QCloud.Cos.Sdk
5.4.0
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Tencent.QCloud.Cos.Sdk --version 5.4.0
NuGet\Install-Package Tencent.QCloud.Cos.Sdk -Version 5.4.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Tencent.QCloud.Cos.Sdk" Version="5.4.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Tencent.QCloud.Cos.Sdk --version 5.4.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Tencent.QCloud.Cos.Sdk, 5.4.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Tencent.QCloud.Cos.Sdk as a Cake Addin #addin nuget:?package=Tencent.QCloud.Cos.Sdk&version=5.4.0 // Install Tencent.QCloud.Cos.Sdk as a Cake Tool #tool nuget:?package=Tencent.QCloud.Cos.Sdk&version=5.4.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
在执行任何和 COS 服务相关请求之前,都需要先实例化CosXmlConfig , QCloudCredentialProvider , CosXmlServer
3个对象. 其中
CosXmlConfig
提供了配置 SDK 的接口.QCloudCredentialProvider
提供了设置密钥信息接口.CosXmlServer
提供了各种 COS API 服务接口
//初始化 CosXmlConfig
string appid = "1250000000";//设置腾讯云账户的账户标识 APPID
string region = "ap-beijing"; //设置一个默认的存储桶地域
CosXmlConfig config = new CosXmlConfig.Builder()
.SetConnectionTimeoutMs(60000) //设置连接超时时间,单位 毫秒 ,默认 45000ms
.SetReadWriteTimeoutMs(40000) //设置读写超时时间,单位 毫秒 ,默认 45000ms
.IsHttps(true) //设置默认 https 请求
.SetAppid(appid) //设置腾讯云账户的账户标识 APPID
.SetRegion(region) //设置一个默认的存储桶地域
.SetDebugLog(true) //显示日志
.Build(); //创建 CosXmlConfig 对象
//初始化 QCloudCredentialProvider ,SDK中提供了3种方式:永久密钥 、 临时密钥 、 自定义
QCloudCredentialProvider cosCredentialProvider = null;
string secretId = "COS_SECRETID"; //"云 API 密钥 SecretId";
string secretKey = "COS_SECRETKEY"; //"云 API 密钥 SecretKey";
long durationSecond = 600; //secretKey 有效时长,单位为 秒
cosCredentialProvider = new DefaultQCloudCredentialProvider(secretId, secretKey, durationSecond);
//初始化 CosXmlServer
CosXmlServer cosXml = new CosXmlServer(config, cosCredentialProvider);
上传对象
try
{
string bucket = "examplebucket-1250000000"; //存储桶,格式:BucketName-APPID
string key = "exampleobject"; //对象在存储桶中的位置,即称对象键.
string srcPath = @"F:\exampleobject";//本地文件绝对路径
PutObjectRequest request = new PutObjectRequest(bucket, key, srcPath);
//设置签名有效时长
request.SetSign(TimeUtils.GetCurrentTime(TimeUnit.SECONDS), 600);
//设置进度回调
request.SetCosProgressCallback(delegate(long completed, long total)
{
Console.WriteLine(String.Format("progress = {1:##.##}%", completed * 100.0 / total));
});
//执行请求
PutObjectResult result = cosXml.PutObject(request);
//请求成功
Console.WriteLine(result.GetResultInfo());
}
catch (COSXML.CosException.CosClientException clientEx)
{
//请求失败
Console.WriteLine("CosClientException: " + clientEx.Message);
}
catch (COSXML.CosException.CosServerException serverEx)
{
//请求失败
Console.WriteLine("CosServerException: " + serverEx.GetInfo());
}
**// 大文件需要使用分片上传(), 可参考 SDK 中封装的 TransferManager 和 COSXMLUploadTask 类, 如下示例 **
TransferManager transferManager = new TransferManager(cosXml, new TransferConfig());
COSXMLUploadTask uploadTask = new COSXMLUploadTask(bucket, null, key);
uploadTask.SetSrcPath(srcPath);
uploadTask.progressCallback = delegate (long completed, long total)
{
Console.WriteLine(String.Format("progress = {1:##.##}%", completed * 100.0 / total));
};
uploadTask.successCallback = delegate (CosResult cosResult)
{
COSXML.Transfer.COSXMLUploadTask.UploadTaskResult result = cosResult as COSXML.Transfer.COSXMLUploadTask.UploadTaskResult;
Console.WriteLine(result.GetResultInfo());
};
uploadTask.failCallback = delegate (CosClientException clientEx, CosServerException serverEx)
{
if (clientEx != null)
{
Console.WriteLine("CosClientException: " + clientEx.Message);
}
if (serverEx != null)
{
Console.WriteLine("CosServerException: " + serverEx.GetInfo());
}
};
transferManager.Upload(uploadTask);
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET Framework | net40 is compatible. net403 was computed. net45 was computed. net451 was computed. net452 was computed. net46 was computed. net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
- Newtonsoft.Json (>= 12.0.1)
NuGet packages (77)
Showing the top 5 NuGet packages that depend on Tencent.QCloud.Cos.Sdk:
Package | Downloads |
---|---|
OnceMi.AspNetCore.OSS
ASP.NET Core对象储存扩展包,支持Minio自建对象储存、阿里云OSS、腾讯云COS、七牛云Kodo、华为云OBS、百度云BOS、天翼云OOS经典版。 |
|
learun.utils
力软开发框架util通用方法 |
|
PiratesCore
湖南医标通信息科技有限公司 |
|
Aiwins.Rocket.Storage.Tencent
Package Description |
|
Coffeehall.Infrastructure
Package Description |
GitHub repositories (14)
Showing the top 5 popular GitHub repositories that depend on Tencent.QCloud.Cos.Sdk:
Repository | Stars |
---|---|
duplicati/duplicati
Store securely encrypted backups in the cloud!
|
|
SciSharp/BotSharp
AI Multi-Agent Framework in .NET
|
|
CoreUnion/CoreShop
基于 Asp.Net Core 8.0、Uni-App开发,支持可视化布局的小程序商城系统,前后端分离,支持分布式部署,跨平台运行,拥有分销、代理、团购、拼团、秒杀、直播、优惠券、自定义表单等众多营销功能,拥有完整SKU、下单、售后、物流流程。支持一套代码编译发布微信小程序版、H5版、Android版、iOS版、支付宝小程序版、字节跳动小程序版、QQ小程序版等共10个平台。
|
|
colinin/abp-next-admin
这是基于vue-vben-admin 模板适用于abp Vnext的前端管理项目
|
|
trueai-org/midjourney-proxy
The most powerful, complete, full-featured, completely free and open source Midjourney API project on the market.
|
Version | Downloads | Last updated |
---|---|---|
5.4.40 | 9,768 | 8/8/2024 |
5.4.39 | 3,585 | 7/25/2024 |
5.4.38 | 6,393 | 6/14/2024 |
5.4.37 | 24,096 | 3/12/2024 |
5.4.36 | 6,771 | 2/2/2024 |
5.4.35 | 54,688 | 8/28/2023 |
5.4.34 | 107,871 | 1/3/2023 |
5.4.32 | 160,957 | 7/22/2022 |
5.4.31 | 45,366 | 6/24/2022 |
5.4.25 | 94,727 | 11/30/2021 |
5.4.24 | 16,945 | 10/13/2021 |
5.4.23 | 55,346 | 9/8/2021 |
5.4.22 | 3,469 | 8/13/2021 |
5.4.21 | 32,965 | 7/1/2021 |
5.4.19 | 32,311 | 5/14/2021 |
5.4.18 | 10,342 | 4/19/2021 |
5.4.17 | 53,975 | 12/18/2020 |
5.4.15 | 9,935 | 11/9/2020 |
5.4.14 | 1,594 | 10/23/2020 |
5.4.13 | 8,092 | 8/24/2020 |
5.4.12 | 752 | 8/20/2020 |
5.4.11 | 99,490 | 6/17/2020 |
5.4.10 | 1,156 | 6/3/2020 |
5.4.9 | 43,713 | 2/24/2020 |
5.4.8 | 4,174 | 11/18/2019 |
5.4.7 | 897 | 10/31/2019 |
5.4.6 | 5,640 | 9/27/2019 |
5.4.5 | 3,162 | 9/18/2019 |
5.4.3 | 1,938 | 9/4/2019 |
5.4.2 | 2,084 | 5/6/2019 |
5.4.1.1 | 1,046 | 3/4/2019 |
5.4.0 | 1,402 | 1/24/2019 |
tencent.qcloud.cos.donet.sdk v5.4.0.0