Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set COS_SECRET to SECRET_, and other bug fixed #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions dotnet/dist/AbortMultiPartsUpload.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ public class AbortMultiPartsUploadModel {
.SetRegion("COS_REGION") //设置一个默认的存储桶地域
.Build();

string secretId = "COS_SECRETID"; //云 API 密钥 SecretId
string secretKey = "COS_SECRETKEY"; //云 API 密钥 SecretKey
string secretId = "SECRET_ID"; //云 API 密钥 SecretId
string secretKey = "SECRET_KEY"; //云 API 密钥 SecretKey
long durationSecond = 600; //每次请求签名有效时长,单位为秒
QCloudCredentialProvider qCloudCredentialProvider = new DefaultQCloudCredentialProvider(secretId,
secretKey, durationSecond);
Expand Down Expand Up @@ -112,4 +112,4 @@ static void Main(string[] args)
// .cssg-methods-pragma
}
}
}
}
104 changes: 104 additions & 0 deletions dotnet/dist/AppendObject.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
using COSXML.Common;
using COSXML.CosException;
using COSXML.Model;
using COSXML.Model.Object;
using COSXML.Model.Tag;
using COSXML.Model.Bucket;
using COSXML.Model.Service;
using COSXML.Utils;
using COSXML.Auth;
using COSXML.Transfer;
using System;
using COSXML;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Net;

using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
using COSXML.Log;
using System.Net.Cache;
using System.Collections;


namespace COSSnippet
{
public class AppendObjectModel {

private static CosXml cosXml;
private static int count = 0;

AppendObjectModel() {
CosXmlConfig config = new CosXmlConfig.Builder()
.SetRegion("") //设置一个默认的存储桶地域
.Build();

string secretId = "SECRET_ID"; //云 API 密钥 SecretId
string secretKey = "SECRET_KEY"; //云 API 密钥 SecretKey
long durationSecond = 600; //每次请求签名有效时长,单位为秒
QCloudCredentialProvider qCloudCredentialProvider = new DefaultQCloudCredentialProvider(secretId,
secretKey, durationSecond);

cosXml = new CosXmlServer(config, qCloudCredentialProvider);
}

/// 简单上传对象
public void AppendObject()
{
//.cssg-snippet-body-start:[Append-object]
try
{
string bucket = "examplebucket-1250000000"; //存储桶,格式:BucketName-APPID
string key = "exampleobject"; //对象键
string srcPath = @"temp-source-file";//本地文件绝对路径

//首次append上传,追加位置传0,创建一个appendable对象
long next_append_position = 0;
AppendObjectRequest request = new AppendObjectRequest(bucket, key, srcPath, next_append_position);
//设置进度回调
request.SetCosProgressCallback(delegate (long completed, long total)
{
Console.WriteLine(String.Format("progress = {0:##.##}%", completed * 100.0 / total));
});
AppendObjectResult result = cosXml.AppendObject(request);
//获取下次追加位置
next_append_position = result.nextAppendPosition;
Console.WriteLine(result.GetResultInfo());

//执行追加,传入上次获取的对象末尾
request = new AppendObjectRequest(bucket, key, srcPath, next_append_position);
request.SetCosProgressCallback(delegate (long completed, long total)
{
Console.WriteLine(String.Format("progress = {0:##.##}%", completed * 100.0 / total));
});
result = cosXml.AppendObject(request);
Console.WriteLine(result.GetResultInfo());
}
catch (COSXML.CosException.CosClientException clientEx)
{
//请求失败
Console.WriteLine("CosClientException: " + clientEx);
}
catch (COSXML.CosException.CosServerException serverEx)
{
//请求失败
Console.WriteLine("CosServerException: " + serverEx.GetInfo());
}

//.cssg-snippet-body-end
}

// .cssg-methods-pragm

static void Main(string[] args)
{
AppendObjectModel m = new AppendObjectModel();
m.AppendObject();
}
}
}
6 changes: 3 additions & 3 deletions dotnet/dist/BucketACL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ public class BucketACLModel {
.SetRegion("COS_REGION") //设置一个默认的存储桶地域
.Build();

string secretId = "COS_SECRETID"; //云 API 密钥 SecretId
string secretKey = "COS_SECRETKEY"; //云 API 密钥 SecretKey
string secretId = "SECRET_ID"; //云 API 密钥 SecretId
string secretKey = "SECRET_KEY"; //云 API 密钥 SecretKey
long durationSecond = 600; //每次请求签名有效时长,单位为秒
QCloudCredentialProvider qCloudCredentialProvider = new DefaultQCloudCredentialProvider(secretId,
secretKey, durationSecond);
Expand Down Expand Up @@ -111,4 +111,4 @@ static void Main(string[] args)
// .cssg-methods-pragma
}
}
}
}
6 changes: 3 additions & 3 deletions dotnet/dist/BucketCORS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ public class BucketCORSModel {
.SetRegion("COS_REGION") //设置一个默认的存储桶地域
.Build();

string secretId = "COS_SECRETID"; //云 API 密钥 SecretId
string secretKey = "COS_SECRETKEY"; //云 API 密钥 SecretKey
string secretId = "SECRET_ID"; //云 API 密钥 SecretId
string secretKey = "SECRET_KEY"; //云 API 密钥 SecretKey
long durationSecond = 600; //每次请求签名有效时长,单位为秒
QCloudCredentialProvider qCloudCredentialProvider = new DefaultQCloudCredentialProvider(secretId,
secretKey, durationSecond);
Expand Down Expand Up @@ -186,4 +186,4 @@ static void Main(string[] args)
// .cssg-methods-pragma
}
}
}
}
6 changes: 3 additions & 3 deletions dotnet/dist/BucketDomain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ public class BucketDomainModel {
.SetRegion("COS_REGION") //设置一个默认的存储桶地域
.Build();

string secretId = "COS_SECRETID"; //云 API 密钥 SecretId
string secretKey = "COS_SECRETKEY"; //云 API 密钥 SecretKey
string secretId = "SECRET_ID"; //云 API 密钥 SecretId
string secretKey = "SECRET_KEY"; //云 API 密钥 SecretKey
long durationSecond = 600; //每次请求签名有效时长,单位为秒
QCloudCredentialProvider qCloudCredentialProvider = new DefaultQCloudCredentialProvider(secretId,
secretKey, durationSecond);
Expand Down Expand Up @@ -124,4 +124,4 @@ static void Main(string[] args)
// .cssg-methods-pragma
}
}
}
}
6 changes: 3 additions & 3 deletions dotnet/dist/BucketInventory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ public class BucketInventoryModel {
.SetRegion("COS_REGION") //设置一个默认的存储桶地域
.Build();

string secretId = "COS_SECRETID"; //云 API 密钥 SecretId
string secretKey = "COS_SECRETKEY"; //云 API 密钥 SecretKey
string secretId = "SECRET_ID"; //云 API 密钥 SecretId
string secretKey = "SECRET_KEY"; //云 API 密钥 SecretKey
long durationSecond = 600; //每次请求签名有效时长,单位为秒
QCloudCredentialProvider qCloudCredentialProvider = new DefaultQCloudCredentialProvider(secretId,
secretKey, durationSecond);
Expand Down Expand Up @@ -152,4 +152,4 @@ static void Main(string[] args)
// .cssg-methods-pragma
}
}
}
}
6 changes: 3 additions & 3 deletions dotnet/dist/BucketLifecycle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ public class BucketLifecycleModel {
.SetRegion("COS_REGION") //设置一个默认的存储桶地域
.Build();

string secretId = "COS_SECRETID"; //云 API 密钥 SecretId
string secretKey = "COS_SECRETKEY"; //云 API 密钥 SecretKey
string secretId = "SECRET_ID"; //云 API 密钥 SecretId
string secretKey = "SECRET_KEY"; //云 API 密钥 SecretKey
long durationSecond = 600; //每次请求签名有效时长,单位为秒
QCloudCredentialProvider qCloudCredentialProvider = new DefaultQCloudCredentialProvider(secretId,
secretKey, durationSecond);
Expand Down Expand Up @@ -148,4 +148,4 @@ static void Main(string[] args)
// .cssg-methods-pragma
}
}
}
}
6 changes: 3 additions & 3 deletions dotnet/dist/BucketLogging.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ public class BucketLoggingModel {
.SetRegion("COS_REGION") //设置一个默认的存储桶地域
.Build();

string secretId = "COS_SECRETID"; //云 API 密钥 SecretId
string secretKey = "COS_SECRETKEY"; //云 API 密钥 SecretKey
string secretId = "SECRET_ID"; //云 API 密钥 SecretId
string secretKey = "SECRET_KEY"; //云 API 密钥 SecretKey
long durationSecond = 600; //每次请求签名有效时长,单位为秒
QCloudCredentialProvider qCloudCredentialProvider = new DefaultQCloudCredentialProvider(secretId,
secretKey, durationSecond);
Expand Down Expand Up @@ -109,4 +109,4 @@ static void Main(string[] args)
// .cssg-methods-pragma
}
}
}
}
6 changes: 3 additions & 3 deletions dotnet/dist/BucketPolicy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ public class BucketPolicyModel {
.SetRegion("COS_REGION") //设置一个默认的存储桶地域
.Build();

string secretId = "COS_SECRETID"; //云 API 密钥 SecretId
string secretKey = "COS_SECRETKEY"; //云 API 密钥 SecretKey
string secretId = "SECRET_ID"; //云 API 密钥 SecretId
string secretKey = "SECRET_KEY"; //云 API 密钥 SecretKey
long durationSecond = 600; //每次请求签名有效时长,单位为秒
QCloudCredentialProvider qCloudCredentialProvider = new DefaultQCloudCredentialProvider(secretId,
secretKey, durationSecond);
Expand Down Expand Up @@ -77,4 +77,4 @@ static void Main(string[] args)
// .cssg-methods-pragma
}
}
}
}
6 changes: 3 additions & 3 deletions dotnet/dist/BucketReplication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ public class BucketReplicationModel {
.SetRegion("COS_REGION") //设置一个默认的存储桶地域
.Build();

string secretId = "COS_SECRETID"; //云 API 密钥 SecretId
string secretKey = "COS_SECRETKEY"; //云 API 密钥 SecretKey
string secretId = "SECRET_ID"; //云 API 密钥 SecretId
string secretKey = "SECRET_KEY"; //云 API 密钥 SecretKey
long durationSecond = 600; //每次请求签名有效时长,单位为秒
QCloudCredentialProvider qCloudCredentialProvider = new DefaultQCloudCredentialProvider(secretId,
secretKey, durationSecond);
Expand Down Expand Up @@ -139,4 +139,4 @@ static void Main(string[] args)
// .cssg-methods-pragma
}
}
}
}
6 changes: 3 additions & 3 deletions dotnet/dist/BucketTagging.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ public class BucketTaggingModel {
.SetRegion("COS_REGION") //设置一个默认的存储桶地域
.Build();

string secretId = "COS_SECRETID"; //云 API 密钥 SecretId
string secretKey = "COS_SECRETKEY"; //云 API 密钥 SecretKey
string secretId = "SECRET_ID"; //云 API 密钥 SecretId
string secretKey = "SECRET_KEY"; //云 API 密钥 SecretKey
long durationSecond = 600; //每次请求签名有效时长,单位为秒
QCloudCredentialProvider qCloudCredentialProvider = new DefaultQCloudCredentialProvider(secretId,
secretKey, durationSecond);
Expand Down Expand Up @@ -143,4 +143,4 @@ static void Main(string[] args)
// .cssg-methods-pragma
}
}
}
}
6 changes: 3 additions & 3 deletions dotnet/dist/BucketVersioning.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ public class BucketVersioningModel {
.SetRegion("COS_REGION") //设置一个默认的存储桶地域
.Build();

string secretId = "COS_SECRETID"; //云 API 密钥 SecretId
string secretKey = "COS_SECRETKEY"; //云 API 密钥 SecretKey
string secretId = "SECRET_ID"; //云 API 密钥 SecretId
string secretKey = "SECRET_KEY"; //云 API 密钥 SecretKey
long durationSecond = 600; //每次请求签名有效时长,单位为秒
QCloudCredentialProvider qCloudCredentialProvider = new DefaultQCloudCredentialProvider(secretId,
secretKey, durationSecond);
Expand Down Expand Up @@ -101,4 +101,4 @@ static void Main(string[] args)
// .cssg-methods-pragma
}
}
}
}
6 changes: 3 additions & 3 deletions dotnet/dist/BucketWebsite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ public class BucketWebsiteModel {
.SetRegion("COS_REGION") //设置一个默认的存储桶地域
.Build();

string secretId = "COS_SECRETID"; //云 API 密钥 SecretId
string secretKey = "COS_SECRETKEY"; //云 API 密钥 SecretKey
string secretId = "SECRET_ID"; //云 API 密钥 SecretId
string secretKey = "SECRET_KEY"; //云 API 密钥 SecretKey
long durationSecond = 600; //每次请求签名有效时长,单位为秒
QCloudCredentialProvider qCloudCredentialProvider = new DefaultQCloudCredentialProvider(secretId,
secretKey, durationSecond);
Expand Down Expand Up @@ -136,4 +136,4 @@ static void Main(string[] args)
// .cssg-methods-pragma
}
}
}
}
6 changes: 3 additions & 3 deletions dotnet/dist/CopyObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ public class CopyObjectModel {
.SetRegion("COS_REGION") //设置一个默认的存储桶地域
.Build();

string secretId = "COS_SECRETID"; //云 API 密钥 SecretId
string secretKey = "COS_SECRETKEY"; //云 API 密钥 SecretKey
string secretId = "SECRET_ID"; //云 API 密钥 SecretId
string secretKey = "SECRET_KEY"; //云 API 密钥 SecretKey
long durationSecond = 600; //每次请求签名有效时长,单位为秒
QCloudCredentialProvider qCloudCredentialProvider = new DefaultQCloudCredentialProvider(secretId,
secretKey, durationSecond);
Expand Down Expand Up @@ -132,4 +132,4 @@ static void Main(string[] args)
// .cssg-methods-pragma
}
}
}
}
6 changes: 3 additions & 3 deletions dotnet/dist/CustomCredentialProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ public CustomQCloudCredentialProvider(): base(null, null, 0L, null) {
public override void Refresh()
{
//... 这里通过腾讯云请求临时密钥
string tmpSecretId = "COS_SECRETID"; //"临时密钥 SecretId";
string tmpSecretKey = "COS_SECRETKEY"; //"临时密钥 SecretKey";
string tmpSecretId = "SECRET_ID"; //"临时密钥 SecretId";
string tmpSecretKey = "SECRET_KEY"; //"临时密钥 SecretKey";
string tmpToken = "COS_TOKEN"; //"临时密钥 token";
long tmpStartTime = 1546861202;//临时密钥有效开始时间,精确到秒
long tmpExpiredTime = 1546862502;//临时密钥有效截止时间,精确到秒
Expand All @@ -34,4 +34,4 @@ public void init() {
}
}

}
}
6 changes: 3 additions & 3 deletions dotnet/dist/DeleteBucket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ public class DeleteBucketModel {
.SetRegion("COS_REGION") //设置一个默认的存储桶地域
.Build();

string secretId = "COS_SECRETID"; //云 API 密钥 SecretId
string secretKey = "COS_SECRETKEY"; //云 API 密钥 SecretKey
string secretId = "SECRET_ID"; //云 API 密钥 SecretId
string secretKey = "SECRET_KEY"; //云 API 密钥 SecretKey
long durationSecond = 600; //每次请求签名有效时长,单位为秒
QCloudCredentialProvider qCloudCredentialProvider = new DefaultQCloudCredentialProvider(secretId,
secretKey, durationSecond);
Expand Down Expand Up @@ -76,4 +76,4 @@ static void Main(string[] args)
// .cssg-methods-pragma
}
}
}
}
6 changes: 3 additions & 3 deletions dotnet/dist/DeleteObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ public class DeleteObjectModel {
.SetRegion("COS_REGION") //设置一个默认的存储桶地域
.Build();

string secretId = "COS_SECRETID"; //云 API 密钥 SecretId
string secretKey = "COS_SECRETKEY"; //云 API 密钥 SecretKey
string secretId = "SECRET_ID"; //云 API 密钥 SecretId
string secretKey = "SECRET_KEY"; //云 API 密钥 SecretKey
long durationSecond = 600; //每次请求签名有效时长,单位为秒
QCloudCredentialProvider qCloudCredentialProvider = new DefaultQCloudCredentialProvider(secretId,
secretKey, durationSecond);
Expand Down Expand Up @@ -171,4 +171,4 @@ static void Main(string[] args)
// .cssg-methods-pragma
}
}
}
}
Loading