コード例 #1
0
ファイル: COSBackend.cs プロジェクト: snamds/duplicati
        public COS(string url, Dictionary <string, string> options)
        {
            _cosOptions = new CosOptions();

            var uri    = new Utility.Uri(url?.Trim());
            var prefix = uri.HostAndPath?.Trim()?.Trim('/')?.Trim('\\');

            if (!string.IsNullOrEmpty(prefix))
            {
                _cosOptions.Path = prefix + "/";
            }

            if (options.ContainsKey(COS_APP_ID))
            {
                _cosOptions.Appid = options[COS_APP_ID];
            }

            if (options.ContainsKey(COS_REGION))
            {
                _cosOptions.Region = options[COS_REGION];
            }

            if (options.ContainsKey(COS_SECRET_ID))
            {
                _cosOptions.SecretId = options[COS_SECRET_ID];
            }

            if (options.ContainsKey(COS_SECRET_KEY))
            {
                _cosOptions.SecretKey = options[COS_SECRET_KEY];
            }

            if (options.ContainsKey(COS_BUCKET))
            {
                _cosOptions.Bucket = options[COS_BUCKET];
            }

            if (options.ContainsKey(COS_STORAGE_CLASS))
            {
                _cosOptions.StorageClass = options[COS_STORAGE_CLASS];
            }
        }
コード例 #2
0
        public WFwCosClient(CosOptions cos, ILogger <WFwCosClient> l, Func <TempCredentialResult> func)
        {
            options = cos;
            logger  = l;

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

            if (cos.UseTemp)
            {
                qCloudCredentialProvider = new CustomQCloudCredentialProvider(func);
            }
            else
            {
                qCloudCredentialProvider = new DefaultQCloudCredentialProvider(options.SecretId, options.SecretKey, options.DurationSec);
            }

            cosXml = new CosXmlServer(config, qCloudCredentialProvider);
        }