我在.Net中使用以下页面提供的API所生成的临时密钥无法操作我的bucket。 API为NuGet中安装的Tencent Cloud API 3.0 SDK for .NET
获取云COS临时密钥:
尝试了使用在上述页面在线调用API生成的临时ID和Key,无法用于以下在线工具的上传文件操作:
对象存储 - Object基本操作 - Put Object:
而且我发现该API提供的临时密钥方法似乎存在bug:
这是我生成临时密钥的方法:
Credential cred = new Credential
{
SecretId = secretId,
SecretKey = secretKey
};
ClientProfile clientProfile = new ClientProfile();
HttpProfile httpProfile = new HttpProfile();
httpProfile.Endpoint = credentialServer;
clientProfile.HttpProfile = httpProfile;
MsClient client = new MsClient(cred, region, clientProfile);
CreateCosSecKeyInstanceRequest req = new CreateCosSecKeyInstanceRequest();
string strParams = "{\"CosRegion\":\"" + region + "\",\"Duration\":" + expireTime + "}";
req = CreateCosSecKeyInstanceRequest.FromJsonString<CreateCosSecKeyInstanceRequest>(strParams);
CreateCosSecKeyInstanceResponse resp = client.CreateCosSecKeyInstance(req).
ConfigureAwait(false).GetAwaiter().GetResult();
string result = AbstractModel.ToJsonString(resp);
return new JsonResult(result);
以上加粗部分的 resp中,CosBucket总是为ms-shield,resp.CosRegion总是为ap-guangzhou,ExpireTime为3600 or 3601 or 3602, resp.CosPrefix总是为pctool/1300222705/20190916/
无论我的传入参数是什么,上述几个属性值为常量。请问这是by design吗?
请问.Net后端该如何正确的生成临时密钥?
相似问题