1234567891011121314151617181920212223242526272829303132 |
- using COSXML.Auth;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class CustomQCloudCredentialProvider : DefaultSessionQCloudCredentialProvider
- {
- QCloudCredentialProvider cosCredentialProvider = new CustomQCloudCredentialProvider();
- // 这里假设开始没有密钥,也可以用初始的临时密钥来初始化
- public CustomQCloudCredentialProvider() : base(null, null, 0L, null)
- {
- ;
- }
- public override void Refresh()
- {
- //... 首先通过腾讯云请求临时密钥
- string tmpSecretId = COSDownLoad.Instance.successCos.credentials.tmpSecretId; //"临时密钥 SecretId", 临时密钥生成和使用指引参见 https://cloud.tencent.com/document/product/436/14048
- string tmpSecretKey = COSDownLoad.Instance.successCos.credentials.tmpSecretKey; //"临时密钥 SecretKey", 临时密钥生成和使用指引参见 https://cloud.tencent.com/document/product/436/14048
- string tmpToken = COSDownLoad.Instance.successCos.credentials.sessionToken; //"临时密钥 token", 临时密钥生成和使用指引参见 https://cloud.tencent.com/document/product/436/14048
- long tmpStartTime = COSDownLoad.Instance.successCos.startTime;//临时密钥有效开始时间,精确到秒
- long tmpExpiredTime = COSDownLoad.Instance.successCos.expiredTime;//临时密钥有效截止时间,精确到秒
- // 调用接口更新密钥
- SetQCloudCredential(tmpSecretId, tmpSecretKey,
- String.Format("{0};{1}", tmpStartTime, tmpExpiredTime), tmpToken);
- }
- }
|