Tencent.QCloud.Cos.Sdk 5.4.0

There is a newer version of this package available.
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                
#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                

在执行任何和 COS 服务相关请求之前,都需要先实例化CosXmlConfig , QCloudCredentialProvider , CosXmlServer3个对象. 其中

  • 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 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.

NuGet packages (75)

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 (13)

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的前端管理项目
dashiell-zhang/NetEngine
基于 .Net 框架搭建的一个基础项目结构
Version Downloads Last updated
5.4.40 7,816 8/8/2024
5.4.39 3,082 7/25/2024
5.4.38 6,004 6/14/2024
5.4.37 23,320 3/12/2024
5.4.36 6,606 2/2/2024
5.4.35 53,771 8/28/2023
5.4.34 104,475 1/3/2023
5.4.32 159,313 7/22/2022
5.4.31 44,467 6/24/2022
5.4.25 94,374 11/30/2021
5.4.24 16,894 10/13/2021
5.4.23 54,961 9/8/2021
5.4.22 3,463 8/13/2021
5.4.21 32,938 7/1/2021
5.4.19 32,281 5/14/2021
5.4.18 10,326 4/19/2021
5.4.17 53,879 12/18/2020
5.4.15 9,913 11/9/2020
5.4.14 1,584 10/23/2020
5.4.13 8,069 8/24/2020
5.4.12 747 8/20/2020
5.4.11 97,076 6/17/2020
5.4.10 1,139 6/3/2020
5.4.9 43,297 2/24/2020
5.4.8 4,163 11/18/2019
5.4.7 892 10/31/2019
5.4.6 5,634 9/27/2019
5.4.5 3,140 9/18/2019
5.4.3 1,932 9/4/2019
5.4.2 2,078 5/6/2019
5.4.1.1 1,040 3/4/2019
5.4.0 1,378 1/24/2019

tencent.qcloud.cos.donet.sdk v5.4.0.0