diff --git a/QCloudCSharpSDK/COSXML/COSXML-Netcore.csproj b/QCloudCSharpSDK/COSXML/COSXML-Netcore.csproj
index 93f1dae..aa74cab 100644
--- a/QCloudCSharpSDK/COSXML/COSXML-Netcore.csproj
+++ b/QCloudCSharpSDK/COSXML/COSXML-Netcore.csproj
@@ -11,7 +11,7 @@
true
Tencent.QCloud.Cos.Sdk
- 5.4.40.0
+ 5.4.41.0
Tencent
Tencent
Tencent Cloud COS(Cloud Object Service) .Net SDK
diff --git a/QCloudCSharpSDK/COSXML/Common/CosVersion.cs b/QCloudCSharpSDK/COSXML/Common/CosVersion.cs
index 40a6716..deaf9ef 100644
--- a/QCloudCSharpSDK/COSXML/Common/CosVersion.cs
+++ b/QCloudCSharpSDK/COSXML/Common/CosVersion.cs
@@ -9,7 +9,8 @@ namespace COSXML.Common
{
public sealed class CosVersion
{
- private static string SDKVersion = "5.4.40.0";
+
+ private static string SDKVersion = "5.4.41.0";
public static string GetUserAgent()
{
diff --git a/QCloudCSharpSDK/COSXML/CosXmlConfig.cs b/QCloudCSharpSDK/COSXML/CosXmlConfig.cs
index 6d1cd06..eb672b8 100644
--- a/QCloudCSharpSDK/COSXML/CosXmlConfig.cs
+++ b/QCloudCSharpSDK/COSXML/CosXmlConfig.cs
@@ -157,6 +157,11 @@ public Builder SetRegion(string region)
"region cannot be empty"
);
}
+ if (region.Contains("@"))
+ {
+ throw new CosException.CosClientException((int)COSXML.Common.CosClientError.InvalidArgument,
+ "region中不能包含特殊字符@");
+ }
this.region = region;
return this;
diff --git a/QCloudCSharpSDK/COSXMLDemo/AccessManage/BucketPolicy.cs b/QCloudCSharpSDK/COSXMLDemo/AccessManage/BucketPolicy.cs
index 69c482b..bf17621 100644
--- a/QCloudCSharpSDK/COSXMLDemo/AccessManage/BucketPolicy.cs
+++ b/QCloudCSharpSDK/COSXMLDemo/AccessManage/BucketPolicy.cs
@@ -38,7 +38,7 @@ private void InitCosXml()
//获取桶的策略
public void GetBucketPolicy()
{
- // string bucket = "examplebucket-1250000000";
+ string bucket = "examplebucket-1250000000";
GetBucketPolicyRequest request = new GetBucketPolicyRequest(bucket);
GetBucketPolicyResult result = cosXml.GetBucketPolicy(request);
Console.WriteLine(result.Data); //返回数据,json格式
@@ -48,7 +48,7 @@ public void GetBucketPolicy()
//删除桶的策略
public void DeleteBucketPolicy()
{
- // string bucket = "examplebucket-1250000000";
+ string bucket = "examplebucket-1250000000";
DeleteBucketPolicyRequest request = new DeleteBucketPolicyRequest(bucket);
DeleteBucketPolicyResult result = cosXml.DeleteBucketPolicy(request);
Console.WriteLine(result.GetResultInfo());
@@ -57,32 +57,38 @@ public void DeleteBucketPolicy()
//设置桶的策略
public void PutBucketPolicy()
{
+ string bucket = "examplebucket-1250000000";
PutBucketPolicyRequest request = new PutBucketPolicyRequest(bucket);
// string region = Environment.GetEnvironmentVariable("COS_REGION");
// string appId = Environment.GetEnvironmentVariable("APPID");
// string resource = "qcs::cos:" + region + ":uid/" + appId + ":" + bucket + "/*";
- // string policy = "{\"Statement\":[{\"Action\":[\"name/cos:PutBucketPolicy\",\"name/cos:GetBucketPolicy\",\"name/cos:DeleteBucketPolicy\"],\"Effect\":\"Allow\",\"Principal\":{\"qcs\":[\"qcs::cam::uin/2832742109:uin/100032069732\"]},\"Resource\":[\"" + resource + "\"]}],\"Version\":\"2.0\"}";
+ // long mainUin = 283274210;
+ // long subUin = 10003206973;
+ // string qcs = "qcs::cam::uin/" + mainUin + ":uin/" + subUin;
+ // string policy = "{\"Statement\":[{\"Action\":[\"name/cos:PutBucketPolicy\",\"name/cos:GetBucketPolicy\",\"name/cos:DeleteBucketPolicy\"],\"Effect\":\"Allow\",\"Principal\":{\"qcs\":[\"" + qcs + "\"]},\"Resource\":[\"" + resource + "\"]}],\"Version\":\"2.0\"}";
+ // Console.WriteLine(policy);
+
string policy = @"{
- ""Statement"": [
- {
- ""Action"": [
- ""name/cos:PutBucketPolicy"",
- ""name/cos:GetBucketPolicy"",
- ""name/cos:DeleteBucketPolicy""
- ],
- ""Effect"": ""Allow"",
- ""Principal"": {
- ""qcs"": [
- ""qcs::cam::uin/100000000011:uin/100000000011""
- ]
- },
- ""Resource"": [
- ""qcs::cos:ap-guangzhou:uid/1250000000:examplebucket-1250000000/*""
- ]
- }
- ],
- ""Version"": ""2.0""
- }";
+ ""Statement"": [
+ {
+ ""Action"": [
+ ""name/cos:PutBucketPolicy"",
+ ""name/cos:GetBucketPolicy"",
+ ""name/cos:DeleteBucketPolicy""
+ ],
+ ""Effect"": ""Allow"",
+ ""Principal"": {
+ ""qcs"": [
+ ""qcs::cam::uin/100000000001:uin/100000000002""
+ ]
+ },
+ ""Resource"": [
+ ""qcs::cos:ap-guangzhou:uid/1250000000:examplebucket-1250000000/*""
+ ]
+ }
+ ],
+ ""Version"": ""2.0""
+ }";
request.SetBucketPolicy(policy);
PutBucketPolicyResult result = cosXml.PutBucketPolicy(request);
Console.WriteLine(result.GetResultInfo());
@@ -91,8 +97,8 @@ public void PutBucketPolicy()
public static void BucketPolicyMain()
{
BucketPolicyModel demo = new BucketPolicyModel();
- // demo.PutBucketPolicy();
- demo.GetBucketPolicy();
+ demo.PutBucketPolicy();
+ // demo.GetBucketPolicy();
// demo.DeleteBucketPolicy();
}
}
diff --git a/QCloudCSharpSDK/COSXMLDemo/DateManage/BucketTagging.cs b/QCloudCSharpSDK/COSXMLDemo/DateManage/BucketTagging.cs
index 146db30..a9bb703 100644
--- a/QCloudCSharpSDK/COSXMLDemo/DateManage/BucketTagging.cs
+++ b/QCloudCSharpSDK/COSXMLDemo/DateManage/BucketTagging.cs
@@ -77,8 +77,14 @@ public void GetBucketTagging()
//执行请求
GetBucketTaggingResult result = cosXml.GetBucketTagging(request);
//请求成功
- Tagging tagging = result.tagging;
- Console.WriteLine(tagging);
+ if (result.tagging != null)
+ {
+ foreach (var tag in result.tagging.tagSet.tags)
+ {
+ Console.WriteLine("key {0} value {1}", tag.key, tag.value);
+ }
+ }
+ Console.WriteLine(result.GetResultInfo());
}
catch (COSXML.CosException.CosClientException clientEx)
{
diff --git a/QCloudCSharpSDK/COSXMLDemo/DateManage/BucketWebsite.cs b/QCloudCSharpSDK/COSXMLDemo/DateManage/BucketWebsite.cs
index 2c8338b..9028bcb 100644
--- a/QCloudCSharpSDK/COSXMLDemo/DateManage/BucketWebsite.cs
+++ b/QCloudCSharpSDK/COSXMLDemo/DateManage/BucketWebsite.cs
@@ -122,4 +122,4 @@ public static void BucketWebsiteMain()
}
}
-}
+}
\ No newline at end of file
diff --git a/QCloudCSharpSDK/COSXMLDemo/DateManage/ObjectTagging.cs b/QCloudCSharpSDK/COSXMLDemo/DateManage/ObjectTagging.cs
index fe1e6bb..c580e36 100644
--- a/QCloudCSharpSDK/COSXMLDemo/DateManage/ObjectTagging.cs
+++ b/QCloudCSharpSDK/COSXMLDemo/DateManage/ObjectTagging.cs
@@ -42,7 +42,7 @@ public void GetObjectTagging()
try
{
// 存储桶名称,此处填入格式必须为 bucketname-APPID, 其中 APPID 获取参考 https://console.cloud.tencent.com/developer
- // string bucket = "examplebucket-1250000000";
+ string bucket = "examplebucket-1250000000";
string key = "exampleobject"; //对象键
GetObjectTaggingRequest request = new GetObjectTaggingRequest(bucket, key);
// 执行请求
@@ -72,7 +72,7 @@ public void DeleteObjectTagging()
try
{
// 存储桶名称,此处填入格式必须为 bucketname-APPID, 其中 APPID 获取参考 https://console.cloud.tencent.com/developer
- // string bucket = "examplebucket-1250000000";
+ string bucket = "examplebucket-1250000000";
string key = "exampleobject"; //对象键
DeleteObjectTaggingRequest request = new DeleteObjectTaggingRequest(bucket, key);
// 执行请求
@@ -95,7 +95,7 @@ public void PutObjectTagging()
try
{
// 存储桶名称,此处填入格式必须为 bucketname-APPID, 其中 APPID 获取参考 https://console.cloud.tencent.com/developer
- // string bucket = "examplebucket-1250000000";
+ string bucket = "examplebucket-1250000000";
string key = "exampleobject"; //对象键
PutObjectTaggingRequest request = new PutObjectTaggingRequest(bucket, key);
// 增加标签键值对
diff --git a/QCloudCSharpSDK/COSXMLDemo/MainProcess.cs b/QCloudCSharpSDK/COSXMLDemo/MainProcess.cs
index 1adb580..2e9c45e 100644
--- a/QCloudCSharpSDK/COSXMLDemo/MainProcess.cs
+++ b/QCloudCSharpSDK/COSXMLDemo/MainProcess.cs
@@ -1,3 +1,5 @@
+using System;
+
namespace COSXMLDemo
{
public class Process
@@ -10,10 +12,10 @@ static void Main(string[] args)
}
public void DoSomething()
- {
- // BucketPolicy.BucketPolicyMain();
+ {
+ // BucketPolicyModel.BucketPolicyMain();
// DownloadObject.DownloadObjectMain();
- // UploadObject.UploadObjectMain();
+ UploadObject.UploadObjectMain();
// GetObjectUrlDemo.GetObjectUrlDemoMain();
// DeleteObjectModel.DeleteObjectModelMain();
@@ -24,24 +26,26 @@ public void DoSomething()
// HeadObjectModel.HeadObjectMain();
// ObjectRestoreModel.ObjectRestoreModelMain();
// GetObjectUrlDemo.GetObjectUrlDemoMain();
-
+
// CreateBucketModel.CreateBucketModelMain();//
// DeleteBucketModel.DeleteObjectModelMain();//
// DoesBucketExistModel.DoesBucketExistModelMain();//
// HeadBucketModel.HeadBucketModelMain();//
// ListBucketModel.ListBucketModelMain();//
// BucketPolicyModel.BucketPolicyMain();
-
+
// BucketVersioningModel.BucketVersioningMain();//
// BucketLifecycleModel.BucketLifecycleMain();
// BucketReplicationModel.BucketReplicationMain();
// BucketLoggingModel.BucketLoggingMain();
-
- ObjectTaggingModel.ObjectTaggingMain();
- BucketInventoryModel.BucketInventoryMain();
- BucketDomainModel.BucketDomainMain();
- PutObjectACLModel.PutObjectACLMain();//
- BucketRefererModel.BucketRefererMain();//
+
+ // BucketTaggingModel.BucketTaggingMain();
+ // ObjectTaggingModel.ObjectTaggingMain();
+ // BucketInventoryModel.BucketInventoryMain();
+ // BucketDomainModel.BucketDomainMain();
+ // PutObjectACLModel.PutObjectACLMain();//
+ // BucketRefererModel.BucketRefererMain();//
+ // BucketWebsiteModel.BucketWebsiteMain();
}
public void SetEnvironmentVariable()
diff --git a/QCloudCSharpSDK/COSXMLDemo/Object/CopyObject.cs b/QCloudCSharpSDK/COSXMLDemo/Object/CopyObject.cs
index 6732e34..9bbe47c 100644
--- a/QCloudCSharpSDK/COSXMLDemo/Object/CopyObject.cs
+++ b/QCloudCSharpSDK/COSXMLDemo/Object/CopyObject.cs
@@ -436,4 +436,4 @@ public static void CopyObjectModelMain()
demo.MoveObject().Wait();
}
}
-}
\ No newline at end of file
+}
diff --git a/QCloudCSharpSDK/COSXMLDemo/Object/GetObjectUrl.cs b/QCloudCSharpSDK/COSXMLDemo/Object/GetObjectUrl.cs
index 8402efd..938e11e 100644
--- a/QCloudCSharpSDK/COSXMLDemo/Object/GetObjectUrl.cs
+++ b/QCloudCSharpSDK/COSXMLDemo/Object/GetObjectUrl.cs
@@ -139,8 +139,7 @@ public void GetObjectUrl()
{
// 存储桶名称,此处填入格式必须为 bucketname-APPID, 其中 APPID 获取参考 https://console.cloud.tencent.com/developer
string bucket = "examplebucket-1250000000";
- string key = "exampleobject"; //对象键
-
+ string key = "object"; //对象键
// 生成链接(默认域名访问)
String url = cosXml.GetObjectUrl(bucket, key);
Console.WriteLine("Object Url is: " + url);
@@ -263,11 +262,11 @@ public static void GetObjectUrlDemoMain()
// // 获取预签名上传链接
// demo.GetPreSignUploadUrl();
// 获取无签名访问链接
- // demo.GetObjectUrl(); //done
+ demo.GetObjectUrl(); //done
// 生成预签名 URL,并在签名中携带 Host
// demo.GetPreSignUrlWithHost();
// // 生成预签名URL,并在签名中携带请求参数
// demo.GetPreSignUrlWithReqParam();
}
}
-}
+}
\ No newline at end of file