Beispiel #1
0
        protected static async Task <List <T> > GetBlobs <T>(string containerName, string prefix = "", int?maxresultsPerQuery = null, BlobListingDetails blobListingDetails = BlobListingDetails.None) where T : ICloudBlob
        {
            var blobContainer = GetBlobContainer(containerName);

            var blobList = new List <T>();
            BlobContinuationToken continuationToken = null;

            try
            {
                do
                {
                    var response = await blobContainer.ListBlobsSegmentedAsync(prefix,
                                                                               true,
                                                                               blobListingDetails,
                                                                               maxresultsPerQuery,
                                                                               continuationToken,
                                                                               null,
                                                                               null).ConfigureAwait(false);

                    continuationToken = response?.ContinuationToken;

                    foreach (var blob in response?.Results?.OfType <T>())
                    {
                        blobList.Add(blob);
                    }
                } while (continuationToken != null);
            }
            catch (Exception e)
            {
                DebugServices.Log(e);
            }

            return(blobList);
        }
        public static async Task <PhotoModel> SavePhoto(byte[] photo, string photoTitle)
        {
            try
            {
                var photoBlob = await SaveBlockBlob(AzureBlobStorageConstants.ContainerName, photo, photoTitle).ConfigureAwait(false);

                return(new PhotoModel {
                    Title = photoBlob.Name, Uri = photoBlob.Uri
                });
            }
            catch (Exception e)
            {
                DebugServices.Log(e);
                return(null);
            }
        }