Beispiel #1
0
 internal static DataContracts.BlobContents GetBlobContents(Storage.StorageAccountInfo accountInfo, string containerName, string blobName)
 {
     Storage.BlobStorage storage = Storage.BlobStorage.Create(accountInfo);
     Storage.BlobContainer container = storage.GetBlobContainer(containerName);
     if (!container.DoesContainerExist()) return null;
     if (!container.DoesBlobExist(blobName)) return null;
     System.IO.MemoryStream ms = new System.IO.MemoryStream();
     Storage.BlobContents contents = new Microsoft.Samples.ServiceHosting.StorageClient.BlobContents(ms);
     container.GetBlob(blobName, contents, true);
     DataContracts.BlobContents result = new global::StorageClientService.DataContracts.BlobContents();
     result.Contents = contents.AsBytes();
     return result;
 }
        public override byte[] Read(string key)
        {
            System.IO.MemoryStream ms = new System.IO.MemoryStream();
            BlobContents contents = new BlobContents(ms);
            try
            {
                BlobProperties properties = (BlobProperties)blobContainer.GetBlob(key, contents, false);
                if (properties == null)
                {
                    return null;
                }
            }
            catch (StorageServerException ex)
            {
                return null;
            }

            return contents.AsBytes();
        }