Example #1
0
        public static IAzureBlobResultSegment ListBlobsSegmentedAsync(
            string containerDirectory,
            string searchDirectory,
            string prefix,
            BlobListing blobListing,
            BlobListingDetails blobListingDetails,
            int?maxResults,
            BlobContinuationToken currentToken)
        {
            if (blobListing == BlobListing.Hierarchical && (blobListingDetails & BlobListingDetails.Snapshots) == BlobListingDetails.Snapshots)
            {
                throw new ArgumentException("Listing snapshots is only supported in flat mode.");
            }

            var numberToSkip = DetermineNumberToSkip(currentToken);

            var resultSegment = blobListing == BlobListing.Flat
                ? FindFilesFlattened(containerDirectory, searchDirectory, prefix, maxResults, numberToSkip)
                : FindFilesHierarchical(containerDirectory, searchDirectory, prefix, maxResults, numberToSkip);

            if ((blobListingDetails & BlobListingDetails.Metadata) == BlobListingDetails.Metadata)
            {
                foreach (var blob in resultSegment.Results.OfType <StandaloneAzureBlockBlob>())
                {
                    blob.FetchAttributes();
                }
            }

            return(resultSegment);
        }
        public static void ListBlobs(CloudBlobContainer blobContainer, BlobListing blobListing, String prefix = null)
        {
            if (blobListing == BlobListing.Flat)
              {
            foreach (var blockBlob in blobContainer.ListBlobs(prefix: null, useFlatBlobListing: true))
            {
              Console.WriteLine("{0,-10} - {1}", @"Blob", ((CloudBlockBlob)blockBlob).Name);
              Console.WriteLine("{0,-10} - {1}", String.Empty, blockBlob.Uri);
            }
              }
              else if (blobListing == BlobListing.Hierarchical)
              {
            foreach (var blockBlob in blobContainer.ListBlobs(prefix: prefix, useFlatBlobListing: false))
            {
              if (blockBlob is CloudBlockBlob)
              {
            Console.WriteLine("{0,-10} - {1}", @"Blob", ((CloudBlockBlob)blockBlob).Name);
            Console.WriteLine("{0,-10} - {1}", String.Empty, blockBlob.Uri);
              }
              else if (blockBlob is CloudBlobDirectory)
              {
            Console.WriteLine("{0,-10} - {1}", @"Directory", ((CloudBlobDirectory)blockBlob).Prefix);
            Console.WriteLine("{0,-10} - {1}", String.Empty, blockBlob.Uri);

            ListBlobs(blobContainer, BlobListing.Hierarchical, ((CloudBlobDirectory)blockBlob).Prefix);
              }
            }
              }
        }
Example #3
0
        public static void ListBlobs(CloudBlobContainer blobContainer, BlobListing blobListing, String prefix = null)
        {
            if (blobListing == BlobListing.Flat)
            {
                foreach (var blockBlob in blobContainer.ListBlobs(prefix: null, useFlatBlobListing: true))
                {
                    Console.WriteLine("{0,-10} - {1}", @"Blob", ((CloudBlockBlob)blockBlob).Name);
                    Console.WriteLine("{0,-10} - {1}", String.Empty, blockBlob.Uri);
                }
            }
            else if (blobListing == BlobListing.Hierarchical)
            {
                foreach (var blockBlob in blobContainer.ListBlobs(prefix: prefix, useFlatBlobListing: false))
                {
                    if (blockBlob is CloudBlockBlob)
                    {
                        Console.WriteLine("{0,-10} - {1}", @"Blob", ((CloudBlockBlob)blockBlob).Name);
                        Console.WriteLine("{0,-10} - {1}", String.Empty, blockBlob.Uri);
                    }
                    else if (blockBlob is CloudBlobDirectory)
                    {
                        Console.WriteLine("{0,-10} - {1}", @"Directory", ((CloudBlobDirectory)blockBlob).Prefix);
                        Console.WriteLine("{0,-10} - {1}", String.Empty, blockBlob.Uri);

                        ListBlobs(blobContainer, BlobListing.Hierarchical, ((CloudBlobDirectory)blockBlob).Prefix);
                    }
                }
            }
        }
Example #4
0
        public static IAzureBlobResultSegment ListBlobsSegmentedAsync(
            string containerDirectory,
            string searchDirectory,
            string prefix,
            BlobListing blobListing,
            BlobListingDetails blobListingDetails,
            int? maxResults,
            BlobContinuationToken currentToken)
        {
            if (blobListing == BlobListing.Hierarchical && (blobListingDetails & BlobListingDetails.Snapshots) == BlobListingDetails.Snapshots)
            {
                throw new ArgumentException("Listing snapshots is only supported in flat mode.");
            }

            var numberToSkip = DetermineNumberToSkip(currentToken);

            var resultSegment = blobListing == BlobListing.Flat
                ? FindFilesFlattened(containerDirectory, searchDirectory, prefix, maxResults, numberToSkip)
                : FindFilesHierarchical(containerDirectory, searchDirectory, prefix, maxResults, numberToSkip);

            if ((blobListingDetails & BlobListingDetails.Metadata) == BlobListingDetails.Metadata)
            {
                foreach (var blob in resultSegment.Results.OfType<StandaloneAzureBlockBlob>())
                {
                    blob.FetchAttributes();
                }
            }

            return resultSegment;
        }
 public async Task<IAzureBlobResultSegment> ListBlobsSegmentedAsync(BlobListing blobListing, BlobListingDetails blobListingDetails, int? maxResults, BlobContinuationToken currentToken)
 {
     return new HostedAzureBlobResultSegment(await _cloudBlobDirectory.ListBlobsSegmentedAsync(
         blobListing == BlobListing.Flat,
         blobListingDetails,
         maxResults,
         currentToken,
         null,
         null));
 }
 public async Task <IAzureBlobResultSegment> ListBlobsSegmentedAsync(BlobListing blobListing, BlobListingDetails blobListingDetails, int?maxResults, BlobContinuationToken currentToken)
 {
     return(new HostedAzureBlobResultSegment(await _cloudBlobDirectory.ListBlobsSegmentedAsync(
                                                 blobListing == BlobListing.Flat,
                                                 blobListingDetails,
                                                 maxResults,
                                                 currentToken,
                                                 null,
                                                 null)));
 }
 public Task <IAzureBlobResultSegment> ListBlobsSegmentedAsync(BlobListing blobListing, BlobListingDetails blobListingDetails, int?maxResults, BlobContinuationToken currentToken)
 {
     return(Task.FromResult(StandaloneList.ListBlobsSegmentedAsync(
                                _containerDirectory,
                                _directoryPath,
                                "",
                                blobListing,
                                blobListingDetails,
                                maxResults,
                                currentToken)));
 }
 public Task<IAzureBlobResultSegment> ListBlobsSegmentedAsync(BlobListing blobListing, BlobListingDetails blobListingDetails, int? maxResults, BlobContinuationToken currentToken)
 {
     return Task.FromResult(StandaloneList.ListBlobsSegmentedAsync(
         _containerDirectory,
         _directoryPath,
         "",
         blobListing,
         blobListingDetails,
         maxResults,
         currentToken));
 }
        public Task<IAzureBlobResultSegment> ListBlobsSegmentedAsync(string prefix, BlobListing blobListing, BlobListingDetails blobListingDetails, int? maxResults, BlobContinuationToken currentToken)
        {
            if (blobListing == BlobListing.Hierarchical && (blobListingDetails & BlobListingDetails.Snapshots) == BlobListingDetails.Snapshots)
            {
                throw new ArgumentException("Listing snapshots is only supported in flat mode.");
            }

            var numberToSkip = DetermineNumberToSkip(currentToken);

            var resultSegment = blobListing == BlobListing.Flat
                ? FindFilesFlattened(prefix, maxResults, numberToSkip)
                : FindFilesHierarchical(prefix, maxResults, numberToSkip);

            return Task.FromResult((IAzureBlobResultSegment) resultSegment);
        }