Exemplo n.º 1
0
        protected override async Task <Blob> GetBlobAsync(string fullPath, CancellationToken cancellationToken)
        {
            CloudFile file = await GetFileReferenceAsync(fullPath, false, cancellationToken).ConfigureAwait(false);

            try
            {
                await file.FetchAttributesAsync(cancellationToken).ConfigureAwait(false);

                return(AzConvert.ToBlob(StoragePath.GetParent(fullPath), file));
            }
            catch (AzStorageException ex) when(ex.RequestInformation.ErrorCode == "ShareNotFound")
            {
                return(null);
            }
            catch (AzStorageException ex) when(ex.RequestInformation.ErrorCode == "ResourceNotFound")
            {
                return(null);
            }
        }
Exemplo n.º 2
0
        protected override async Task <IReadOnlyCollection <Blob> > ListAtAsync(
            string path, ListOptions options, CancellationToken cancellationToken)
        {
            if (StoragePath.IsRootPath(path))
            {
                //list file shares

                ShareResultSegment shares = await _client.ListSharesSegmentedAsync(null, cancellationToken).ConfigureAwait(false);

                return(shares.Results.Select(AzConvert.ToBlob).ToList());
            }
            else
            {
                var chunk = new List <Blob>();

                CloudFileDirectory dir = await GetDirectoryReferenceAsync(path, cancellationToken).ConfigureAwait(false);

                FileContinuationToken token = null;
                do
                {
                    try
                    {
                        FileResultSegment segment = await dir.ListFilesAndDirectoriesSegmentedAsync(options.FilePrefix, token, cancellationToken).ConfigureAwait(false);

                        token = segment.ContinuationToken;

                        chunk.AddRange(segment.Results.Select(r => AzConvert.ToBlob(path, r)));
                    }
                    catch (AzStorageException ex) when(ex.RequestInformation.ErrorCode == "ShareNotFound")
                    {
                        break;
                    }
                    catch (AzStorageException ex) when(ex.RequestInformation.ErrorCode == "ResourceNotFound")
                    {
                        break;
                    }
                }while(token != null);

                return(chunk);
            }
        }