public async Task <List <Item> > ListObjectsAsync(string bucketName, string prefix = null) { if (string.IsNullOrEmpty(bucketName)) { throw new ArgumentNullException(nameof(bucketName)); } bucketName = ConvertBucketName(bucketName); ListBucket info = null; string nextMarker = null; List <Item> items = new List <Item>(); do { GetBucketRequest request = new GetBucketRequest(bucketName); if (!string.IsNullOrEmpty(nextMarker)) { request.SetMarker(nextMarker); } if (!string.IsNullOrEmpty(prefix)) { request.SetPrefix(prefix); } //执行请求 GetBucketResult result = _client.GetBucket(request); //bucket的相关信息 info = result.listBucket; if (info.isTruncated) { // 数据被截断,记录下数据下标 nextMarker = info.nextMarker; } foreach (var item in info.contentsList) { items.Add(new Item() { Key = item.key, LastModified = item.lastModified, ETag = item.eTag, Size = (ulong)item.size, IsDir = false, BucketName = bucketName, VersionId = null, }); } } while (info.isTruncated); return(await Task.FromResult(items)); }
public void getBucket() { //.cssg-snippet-body-start:[get-bucket] CosXmlConfig config = new CosXmlConfig.Builder() .SetConnectionTimeoutMs(60000) //设置连接超时时间,单位毫秒,默认45000ms .SetReadWriteTimeoutMs(40000) //设置读写超时时间,单位毫秒,默认45000ms .IsHttps(true) //设置默认 HTTPS 请求 .SetAppid("1253653367") //设置腾讯云账户的账户标识 APPID .SetRegion("ap-guangzhou") //设置一个默认的存储桶地域 .Build(); string secretId = Environment.GetEnvironmentVariable("COS_KEY"); //云 API 密钥 SecretId string secretKey = Environment.GetEnvironmentVariable("COS_SECRET"); //云 API 密钥 SecretKey long durationSecond = 600; //每次请求签名有效时长,单位为秒 QCloudCredentialProvider qCloudCredentialProvider = new DefaultQCloudCredentialProvider(secretId, secretKey, durationSecond); CosXml cosXml = new CosXmlServer(config, qCloudCredentialProvider); try { string bucket = "bucket-cssg-test-dotnet-1253653367"; //格式:BucketName-APPID GetBucketRequest request = new GetBucketRequest(bucket); //设置签名有效时长 request.SetSign(TimeUtils.GetCurrentTime(TimeUnit.SECONDS), 600); //获取 a/ 下的对象 request.SetPrefix("a/"); //执行请求 GetBucketResult result = cosXml.GetBucket(request); //bucket的相关信息 ListBucket info = result.listBucket; } catch (COSXML.CosException.CosClientException clientEx) { //请求失败 Console.WriteLine("CosClientException: " + clientEx); Assert.Null(clientEx); } catch (COSXML.CosException.CosServerException serverEx) { //请求失败 Console.WriteLine("CosServerException: " + serverEx.GetInfo()); Assert.Null(serverEx); } //.cssg-snippet-body-end }
/// <summary> /// Consolidates the trees in this heap so there's at most 1 tree per tree degree. It also finds the root of the tree (min/max) and sets _heapRoot. /// </summary> private void ConsolidateTrees() { Dictionary <int, ListBucket <FibonacciHeapNode <TElement> > > treeNodePerDegree = new Dictionary <int, ListBucket <FibonacciHeapNode <TElement> > >(); if (_trees.Count < 2) { // nothing to do return; } // traverse the trees and if there's no tree with such a degree, add it to the list, otherwise merge the tree with the one already with that // degree till there's no tree with that degree left. ListBucket <FibonacciHeapNode <TElement> > currentTreeNode = _trees.Head; while (currentTreeNode != null) { ListBucket <FibonacciHeapNode <TElement> > treeNodeWithSameDegree; if (treeNodePerDegree.TryGetValue(currentTreeNode.Contents.Degree, out treeNodeWithSameDegree)) { // there's a tree with the same node. Merge this tree with that tree till there's no tree with the same degree for this current tree treeNodePerDegree.Remove(currentTreeNode.Contents.Degree); _trees.Remove(treeNodeWithSameDegree); // merge trees. It depends on the nodes which one is added to which as a child. if (this.ElementCompareFunc(treeNodeWithSameDegree.Contents.Contents, currentTreeNode.Contents.Contents)) { // add currenttreenode's tree as child to treeNodeWithSameDegree treeNodeWithSameDegree.Contents.AddChild(currentTreeNode.Contents); // place the tree inside the currenttreenode's linkedlist node. currentTreeNode.Contents = treeNodeWithSameDegree.Contents; } else { currentTreeNode.Contents.AddChild(treeNodeWithSameDegree.Contents); } } else { // not a tree with this degree treeNodePerDegree.Add(currentTreeNode.Contents.Degree, currentTreeNode); // move to next node. currentTreeNode = currentTreeNode.Next; continue; } } }
internal override void ParseResponseBody(System.IO.Stream inputStream, string contentType, long contentLength) { listBucket = new ListBucket(); XmlParse.ParseListBucket(inputStream, listBucket); }
/// <summary> /// Moves the current command to the next command in the queue. /// </summary> private void MoveNext() { _currentCommandBucket = _currentCommandBucket == null ? _commands.Head : _currentCommandBucket.Next; }
/// <summary> /// Clears this instance. /// </summary> public void Clear() { _commands.Clear(); _currentCommandBucket = null; }