Example #1
0
        public virtual async Task <IEnumerable <Blob> > ListBlobsAsync(CancellationToken cancellationToken)
        {
            if (string.IsNullOrWhiteSpace(Id))
            {
                throw ExceptionGenerator.InvalidOperationException("ListBlobs", this.Name, "Container");
            }

            var serviceResponse = await _containersApi.ListContainerBlobsAsync(this.Id);

            cancellationToken.ThrowIfCancellationRequested();

            if (false == serviceResponse.ResponseMessage.IsSuccessStatusCode)
            {
                throw ExceptionGenerator.GeneralFailureException(serviceResponse.StringContent.ToString());
            }

            var containerBlobDTOs = serviceResponse.GetContent();

            return(containerBlobDTOs.Select(b => new Blob(this.ServiceClient, this, b.Id, b.OrigFileName, b.MimeType, b.SizeInBytes, b.DownloadRelativeUrl)));
        }