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

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

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!
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 框架搭建的一个基础项目结构
xpnas/yopngs
纯粹图床,支持鉴黄,支持压缩,支持本地存储,COS存储,OSS存储,B2存储
Version Downloads Last updated
5.4.37 3,858 3/12/2024
5.4.36 2,540 2/2/2024
5.4.35 35,968 8/28/2023
5.4.34 63,093 1/3/2023
5.4.32 116,341 7/22/2022
5.4.31 32,157 6/24/2022
5.4.25 82,758 11/30/2021
5.4.24 16,290 10/13/2021
5.4.23 48,307 9/8/2021
5.4.22 3,382 8/13/2021
5.4.21 31,946 7/1/2021
5.4.19 31,466 5/14/2021
5.4.18 10,073 4/19/2021
5.4.17 50,136 12/18/2020
5.4.15 9,320 11/9/2020
5.4.14 1,512 10/23/2020
5.4.13 7,543 8/24/2020
5.4.12 735 8/20/2020
5.4.11 81,156 6/17/2020
5.4.10 1,081 6/3/2020
5.4.9 41,500 2/24/2020
5.4.8 3,996 11/18/2019
5.4.7 866 10/31/2019
5.4.6 5,532 9/27/2019
5.4.5 2,778 9/18/2019
5.4.3 1,839 9/4/2019
5.4.2 1,982 5/6/2019
5.4.1.1 1,011 3/4/2019
5.4.0 1,321 1/24/2019

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