public QCloudCOS(string appid, string region, string secretId, string secretKey, string bucket) { _bucket = bucket; //初始化 CosXmlConfig //string appid = "1258572948";//设置腾讯云账户的账户标识 APPID //string region = "ap-chengdu"; //设置一个默认的存储桶地域 // string secretId = "AKIDKi1vlbNKDvSqOtPONBsPkfdOyNdhGWxS"; //"云 API 密钥 SecretId"; // string secretKey = "Vq14wcIe1wt3HNK1ksCMj4LVBlEcgls3"; //"云 API 密钥 SecretKey"; config = new CosXmlConfig.Builder() .SetConnectionTimeoutMs(5000) //设置连接超时时间,单位 毫秒 ,默认 45000ms .SetReadWriteTimeoutMs(5000) //设置读写超时时间,单位 毫秒 ,默认 45000ms .IsHttps(true) //设置默认 https 请求 .SetAppid(appid) //设置腾讯云账户的账户标识 APPID .SetRegion(region) //设置一个默认的存储桶地域 .SetDebugLog(true) //显示日志 .Build(); //创建 CosXmlConfig 对象 //方式1, 永久密钥 long durationSecond = 600; //secretKey 有效时长,单位为 秒 cosCredentialProvider = new DefaultQCloudCredentialProvider(secretId, secretKey, durationSecond); //初始化 CosXmlServer cosXml = new CosXmlServer(config, cosCredentialProvider); }
/// <summary> /// 初始化CosService类 /// </summary> public CosService(string region) { config = new CosXmlConfig.Builder() .IsHttps(true) //设置默认 HTTPS 请求 .SetRegion(region) //设置一个默认的存储桶地域 .SetDebugLog(true) //显示日志 .Build(); //创建 CosXmlConfig 对象 }
public CosBuilder SetCosXmlServer(int ConnectionTimeoutMs = 60000, int ReadWriteTimeoutMs = 40000, bool IsHttps = true, bool SetDebugLog = true) { cosXmlConfig = new CosXmlConfig.Builder() .SetConnectionTimeoutMs(ConnectionTimeoutMs) .SetReadWriteTimeoutMs(ReadWriteTimeoutMs) .IsHttps(true) .SetAppid(_appid) .SetRegion(_region) .SetDebugLog(true) .Build(); return(this); }
public QcloudStorageService(string[] args) { // args: "qcloud" | bucket | region | secret_id | secret_key bucket = args[1]; cosConfig = new CosXmlConfig.Builder() .IsHttps(true) .SetAppid(args[1].Split('-').Last()) .SetRegion(args[2]) .Build(); var cred = new DefaultQCloudCredentialProvider(args[3], args[4], 120); cos = new CosXmlServer(cosConfig, cred); }
private void init(string projectId) { ucbFacade = new UcbFacade(); // ucbFacade.setHost("http://localhost"); ucbFacade.setHost("https://api.ccb.unity.cn"); ucbFacade.setPort("443"); CosInfo cosInfo = ucbFacade.GetCredential(projectId); sourceBucket = cosInfo.bucket; deltaBucket = cosInfo.deltaBucket; cosConfig = new CosXmlConfig.Builder() .SetConnectionTimeoutMs(60000) //ms .SetReadWriteTimeoutMs(40000) //ms .IsHttps(true) .SetAppid(cosInfo.appId) .SetRegion(cosInfo.region) .SetDebugLog(true) .Build(); cosProvider = new UcbSessionQCloudCredentialProvider(cosInfo.secretId, cosInfo.secretKey, cosInfo.expireTime, cosInfo.token, projectId, ucbFacade); cosXml = new CosXmlServer(cosConfig, cosProvider); transferManager = new TransferManager(cosXml, new TransferConfig()); }