private byte[] loadServiceFabricCertificate()
        {
            try
            {
                StorageCredentials  creds      = new StorageCredentials(_CertStorageName, _CertStorageKey);
                CloudStorageAccount strAcc     = new CloudStorageAccount(creds, true);
                CloudBlobClient     blobClient = strAcc.CreateCloudBlobClient();

                string certStore     = _SrvFabricCertificate;
                int    div           = certStore.IndexOf("/");
                string containerName = certStore.Substring(0, div);
                string certFile      = certStore.Substring(div + 1, certStore.Length - (div + 1));

                CloudBlobContainer container = blobClient.GetContainerReference(containerName);
                CloudBlockBlob     blockBlob = container.GetBlockBlobReference(certFile);
                blockBlob.FetchAttributes();
                byte[] certbytes = new byte[blockBlob.Properties.Length];
                blockBlob.DownloadToByteArray(certbytes, 0);
                return(certbytes);
            }
            catch (Exception)
            {
                throw;
            }
        }
Beispiel #2
0
        public async Task <IHttpActionResult> DownloadFile()
        {
            if (ClaimsPrincipal.Current.FindFirst("http://schemas.microsoft.com/identity/claims/scope").Value != "user_impersonation")
            {
                throw new HttpResponseException(new HttpResponseMessage {
                    StatusCode = HttpStatusCode.Unauthorized, ReasonPhrase = "The Scope claim does not contain 'user_impersonation' or scope claim not found"
                });
            }

            Claim subject = ClaimsPrincipal.Current.FindFirst(ClaimTypes.NameIdentifier);

            CustomerFile custFile = await ProcessCustomerFileData();

            CloudBlobContainer container = GetContainer();

            custFile = SqlDBRepository.GetLegalDocumentData(custFile.Id);

            CloudBlobDirectory caseDirectory = container.GetDirectoryReference("case" + custFile.CaseId.ToString().ToLower());
            CloudBlockBlob     blockBlob     = caseDirectory.GetBlockBlobReference(custFile.Id.ToString() + "_" + custFile.DocumentType);

            blockBlob.FetchAttributes();
            byte[] byteData = new byte[blockBlob.Properties.Length];
            blockBlob.DownloadToByteArray(byteData, 0);

            custFile.DocumentData = byteData;

            return(Ok(custFile));
        }
Beispiel #3
0
        public override Object Download(int companyId, string documentPath)
        {
            //Sample BLOB URL : https://midasdocument.blob.core.windows.net/company-16/cs-86/nofault/consent/consent.pdf
            util.ContainerName = "company-" + companyId;
            string         blobName = util.getBlob(documentPath);
            CloudBlockBlob _cblob   = util.BlobContainer.GetBlockBlobReference(blobName);
            //_cblob.FetchAttributes();

            var ms = new MemoryStream();

            _cblob.DownloadToStream(ms);

            long fileByteLength = _cblob.Properties.Length;

            byte[] fileContents = new byte[fileByteLength];
            _cblob.DownloadToByteArray(fileContents, 0);

            HttpContext.Current.Response.ContentType = _cblob.Properties.ContentType;
            HttpContext.Current.Response.AddHeader("Content-Disposition", "Attachment; filename=" + Path.GetFileName(blobName.ToString()));
            HttpContext.Current.Response.AddHeader("Content-Length", _cblob.Properties.Length.ToString());
            HttpContext.Current.Response.BinaryWrite(fileContents);


            return((Object)ms);
        }
Beispiel #4
0
        public ActionResult Downloads(int id)
        {
            SSMEntities         se             = new SSMEntities();
            order               or             = se.orders.Find(id);
            CloudStorageAccount storageAccount = CloudStorageAccount.Parse("UseDevelopmentStorage=true");

            // Create the blob client.
            CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();

            // Retrieve reference to a previously created container.
            CloudBlobContainer container = blobClient.GetContainerReference(or.customer.userID);

            container.CreateIfNotExists();
            // Retrieve reference to a blob named "myblob".
            CloudBlockBlob blockBlob = container.GetBlockBlobReference("order" + or.id);

            blockBlob.FetchAttributes();
            long fileByteLength = blockBlob.Properties.Length;

            byte[] fileContent = new byte[fileByteLength];
            for (int i = 0; i < fileByteLength; i++)
            {
                fileContent[i] = 0x20;
            }
            blockBlob.DownloadToByteArray(fileContent, 0);
            return(File(fileContent, "application/pdf", "Contract"));
        }
Beispiel #5
0
        private byte[] loadServiceFabricCertificate()
        {
            try
            {
                StorageCredentials  creds      = new StorageCredentials(ConfigurationManager.AppSettings["sfLogStorageName"], ConfigurationManager.AppSettings["sfLogStorageKey"]);
                CloudStorageAccount strAcc     = new CloudStorageAccount(creds, true);
                CloudBlobClient     blobClient = strAcc.CreateCloudBlobClient();

                string certStore     = ConfigurationManager.AppSettings["sfSrvFabricCertificate"];
                int    div           = certStore.IndexOf("/");
                string containerName = certStore.Substring(0, div);
                string certFile      = certStore.Substring(div + 1, certStore.Length - (div + 1));

                CloudBlobContainer container = blobClient.GetContainerReference(containerName);
                CloudBlockBlob     blockBlob = container.GetBlockBlobReference(certFile);
                blockBlob.FetchAttributes();
                byte[] certbytes = new byte[blockBlob.Properties.Length];
                blockBlob.DownloadToByteArray(certbytes, 0);
                return(certbytes);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                throw;
            }
        }
        public static byte[] GetImageAsByteArray(string handle)
        {
            CloudStorageAccount storageAcct = CloudStorageAccount.Parse(connectionString);
            CloudBlobClient     blobClient  = storageAcct.CreateCloudBlobClient();
            CloudBlobContainer  container   = blobClient.GetContainerReference(containerName);

            string         imageName = String.Concat(handle, ".jpg");
            CloudBlockBlob blob      = container.GetBlockBlobReference(imageName);

            if (!blob.Exists())
            {
                blob = container.GetBlockBlobReference(defaultImage);
            }

            blob.FetchAttributes();
            long fileLength = blob.Properties.Length;

            byte[] fileBytes = new byte[fileLength];

            for (long i = 0; i < fileLength; i++)
            {
                fileBytes[i] = 0x20;
            }

            blob.DownloadToByteArray(fileBytes, 0);
            return(fileBytes);
        }
Beispiel #7
0
        private static byte[] GetBlob(CloudBlobContainer container, string caseId)
        {
            CloudBlockBlob blockBlob = container.GetBlockBlobReference("case" + caseId.ToString().ToLower());

            blockBlob.FetchAttributes();
            byte[] byteData = new byte[blockBlob.Properties.Length];
            blockBlob.DownloadToByteArray(byteData, 0);
            return(byteData);
        }
        public static Byte[] ReadImage(Guid pictureGuid)
        {
            CloudBlockBlob blob = BlobHandler.Connect(pictureGuid);

            blob.FetchAttributes();
            Byte[] result = new Byte[blob.Properties.Length];
            blob.DownloadToByteArray(result, 0);
            return(result);
        }
        // GET: MyAccount
        public ActionResult Index()
        {
            if (User.Identity.GetUserId() == null)
            {
                return(RedirectToAction("Index", "Manage"));
            }

            string id = User.Identity.GetUserId();

            ApplicationUser employee = _context.Users.SingleOrDefault(emp => emp.Id == id);

            employee.DisplayName = profileVM.DisplayName;
            if (employee != null)
            {
                employee.RoleNames = (from r in roleManager.Roles.ToList()
                                      from u in r.Users
                                      where u.UserId == employee.Id
                                      select r.Name).ToList();

                //get user image
                string              storageAccountName  = "aspnetpersoncontrol";
                string              keyOne              = "GfiRnxHVXsaluga4L4R0zZOy4Ken4VnF3xM7I66OC263LJ9Sf2BOQgX41+/WpBlA8vMB5aP4wN/Uh00OF4MdXw==";
                string              nameOfStorage       = "storage";
                StorageCredentials  storageCredentials  = new StorageCredentials(storageAccountName, keyOne);
                CloudStorageAccount cloudStorageAccount = new CloudStorageAccount(storageCredentials, true);
                CloudBlobClient     cloudBlobClient     = cloudStorageAccount.CreateCloudBlobClient();

                //get users folder
                CloudBlobContainer cloudBlobContainer = cloudBlobClient.GetContainerReference(nameOfStorage);
                //get users folder
                string             userFolder         = ((ApplicationUser)_context.Users.SingleOrDefault(u => u.Id == id)).Email;
                CloudBlobDirectory cloudBlobDirectory = cloudBlobContainer.GetDirectoryReference(userFolder);
                //add file to sub dir
                CloudBlockBlob cloudBlockBlob = cloudBlobDirectory.GetBlockBlobReference("AccountImage.jpg");
                try
                {
                    cloudBlockBlob.FetchAttributes();
                    long fileByteLength = cloudBlockBlob.Properties.Length;
                    employee.img = new byte[fileByteLength];
                    for (int i = 0; i < fileByteLength; i++)
                    {
                        employee.img[i] = 0x20;
                    }
                    cloudBlockBlob.DownloadToByteArray(employee.img, 0);
                }
                catch
                {
                    employee.img = new byte[8];
                }

                return(View(employee));
            }
            else
            {
                return(RedirectToAction("Index", "Manage"));
            }
        }
Beispiel #10
0
        public byte[] GetBytesFromBlobStorage(string ContainerName, string BlobName)
        {
            GetContainer(ContainerName);
            CloudBlockBlob blockBlob = BlobContainer.GetBlockBlobReference(BlobName);

            blockBlob.FetchAttributes();
            byte[] byteArray = new byte[blockBlob.Properties.Length];
            blockBlob.DownloadToByteArray(byteArray, 0);
            return(byteArray);
        }
Beispiel #11
0
        public byte[] RetrieveBodyAsBytes(BrokeredMessage msg)
        {
            CloudBlockBlob blockBlob = GetReferenceToBlob(msg);

            blockBlob.FetchAttributes();
            long fileByteLength = blockBlob.Properties.Length;

            byte[] target = new byte[fileByteLength];
            blockBlob.DownloadToByteArray(target, 0);
            return(target);
        }
Beispiel #12
0
        /// <summary>
        /// Verify if this blob was previously backed up
        /// </summary>
        /// <param name="blockBlob">CloudBlockBlob instance</param>
        /// <param name="compressedByteArray">Compressed byte array containing the list of documents in GZip compressed form</param>
        /// <returns></returns>
        private bool VerifyIfBlobPreviouslyBackedUp(CloudBlockBlob blockBlob, byte[] compressedByteArray)
        {
            bool isPreviouslyBackedUp = false;

            blockBlob.FetchAttributes();

            byte[] byteArray = new byte[blockBlob.Properties.Length];
            blockBlob.DownloadToByteArray(byteArray, 0);

            isPreviouslyBackedUp = StructuralComparisons.StructuralEqualityComparer.Equals(byteArray, compressedByteArray);
            return(isPreviouslyBackedUp);
        }
        public static byte[] DownloadStream(this CloudBlobContainer cloudBlobContainer, string remoteBlobName)
        {
            CloudBlockBlob blob = cloudBlobContainer.GetBlockBlobReference(remoteBlobName);

            blob.FetchAttributes();
            long fileByteLength = blob.Properties.Length;

            Byte[] result     = new Byte[fileByteLength];
            int    downloaded = blob.DownloadToByteArray(result, 0);

            return(result);
        }
Beispiel #14
0
        public byte[] GetRemoteFile(string curBlobUrl)
        {
            CloudBlobClient curCloudBlobClient = GetDefaultBlobContainer().ServiceClient;
            var             curBlob            = new CloudBlockBlob(new Uri(curBlobUrl), curCloudBlobClient.Credentials);

            curBlob.FetchAttributes();

            byte[] content = new byte[curBlob.Properties.Length];
            curBlob.DownloadToByteArray(content, 0, options: curCloudBlobClient.DefaultRequestOptions);

            return(content);
        }
        public static byte[] GetFileContent(string fileName)
        {
            CloudBlockBlob blockBlob = new CloudBlockBlob(new System.Uri(fileName));

            blockBlob.FetchAttributes();
            long fileByteLength = blockBlob.Properties.Length;

            byte[] fileContent = new byte[fileByteLength];

            blockBlob.DownloadToByteArray(fileContent, 0);
            return(fileContent);
        }
Beispiel #16
0
        //public byte[] GetBlob(string containerName, string blobName)
        //{
        //    CloudBlobContainer container = _blobClient.GetContainerReference(containerName);
        //    _blockBlob = container.GetBlockBlobReference(blobName);
        //    _blockBlob.FetchAttributes();

        //    long fileByteLength = _blockBlob.Properties.Length;
        //    byte[] fileContents = new byte[fileByteLength];
        //    _blockBlob.DownloadToByteArray(fileContents, 0);

        //    return fileContents;
        //}

        /// <summary>
        /// Downloads the contents of a blob into a byte[]
        /// </summary>
        /// <param name="blobName">The name of the blob to download</param>
        /// <returns>byte[] with the blob's contents</returns>

        public byte[] GetBlob(string blobName)
        {
            _blockBlob = _container.GetBlockBlobReference(blobName);
            _blockBlob.FetchAttributes();

            long fileByteLength = _blockBlob.Properties.Length;

            byte[] fileContents = new byte[fileByteLength];
            _blockBlob.DownloadToByteArray(fileContents, 0);

            return(fileContents);
        }
        /// <summary>
        /// Download the file
        /// </summary>
        /// <param name="fileName">name of file on azure</param>
        /// <returns>an array of byte</returns>
        public byte[] Download(string fileName)
        {
            CloudBlobContainer container = this._blobClient.GetContainerReference(this._authentication.ContainerName);
            CloudBlockBlob     blockBlob = container.GetBlockBlobReference(fileName.ToLower());

            blockBlob.FetchAttributes();
            long fileByteLength = blockBlob.Properties.Length;

            byte[] file = new byte[fileByteLength];
            blockBlob.DownloadToByteArray(file, 0);
            return(file);
        }
        public Byte[] DownloadToByteArray(string blobName)
        {
            CloudBlockBlob blob = BlobContainer.GetBlockBlobReference(blobName);

            //you have to fetch the attributes to read the length
            blob.FetchAttributes();
            long fileByteLength = blob.Properties.Length;

            Byte[] myByteArray = new Byte[fileByteLength];
            blob.DownloadToByteArray(myByteArray, 0);
            return(myByteArray);
        }
Beispiel #19
0
        public byte[] GetPDFSol(string id_pdfsol)
        {
            CloudBlobClient    cliente    = storageAccount.CreateCloudBlobClient();
            CloudBlobContainer contenedor = cliente.GetContainerReference("losheroesblob");
            CloudBlockBlob     blockBlob  = contenedor.GetBlockBlobReference(id_pdfsol);

            blockBlob.FetchAttributes();
            long fileByteLength = blockBlob.Properties.Length;

            Byte[] auxiliar = new Byte[fileByteLength];
            blockBlob.DownloadToByteArray(auxiliar, 0);
            return(auxiliar);
        }
Beispiel #20
0
        /// <summary>
        /// Return a bool indicating whether a local file content is same as
        /// the content of the pointed blob. If the blob has the ContentMD5
        /// property set the comparison is performed uniquely using that.
        /// Otherwise a byte-per-byte comparison with the content of the file
        /// is performed.
        /// </summary>
        public async Task <bool> IsFileIdenticalToBlob(string localFileFullPath, CloudBlockBlob blobReference)
        {
            blobReference.FetchAttributes();

            if (!string.IsNullOrEmpty(blobReference.Properties.ContentMD5))
            {
                var localMD5 = CalculateMD5(localFileFullPath);
                var blobMD5  = blobReference.Properties.ContentMD5;

                return(blobMD5.Equals(localMD5, StringComparison.OrdinalIgnoreCase));
            }
            else
            {
                int OneMegaBytes = 1 * 1024 * 1024;

                if (blobReference.Properties.Length < OneMegaBytes)
                {
                    byte[] existingBytes = new byte[blobReference.Properties.Length];
                    byte[] localBytes    = File.ReadAllBytes(localFileFullPath);

                    blobReference.DownloadToByteArray(existingBytes, 0);

                    return(localBytes.SequenceEqual(existingBytes));
                }
                else
                {
                    using (Stream localFileStream = File.OpenRead(localFileFullPath))
                        using (Stream blobStream = await blobReference.OpenReadAsync())
                        {
                            byte[] localBuffer    = new byte[OneMegaBytes];
                            byte[] remoteBuffer   = new byte[OneMegaBytes];
                            int    bytesLocalFile = 0;

                            do
                            {
                                bytesLocalFile = await blobStream.ReadAsync(remoteBuffer, 0, OneMegaBytes);

                                int bytesBlobFile = await localFileStream.ReadAsync(localBuffer, 0, OneMegaBytes);

                                if ((bytesLocalFile != bytesBlobFile) || !remoteBuffer.SequenceEqual(localBuffer))
                                {
                                    return(false);
                                }
                            }while (bytesLocalFile > 0);

                            return(true);
                        }
                }
            }
        }
Beispiel #21
0
        /// <inheritdoc />
        public async Task <string> GetBlobBase64Async(string blobName)
        {
            var cloudBlobContainer = await _connectionFactory.GetBlobContainer(_containerNameKey);

            CloudBlockBlob blockBlob = cloudBlobContainer.GetBlockBlobReference(blobName);

            blockBlob.FetchAttributes();
            byte[] arr = new byte[blockBlob.Properties.Length];
            blockBlob.DownloadToByteArray(arr, 0);
            var azureBase64 = Convert.ToBase64String(arr);
            var result      = $"data:application/{Path.GetExtension(blobName)};base64," + azureBase64;

            return(result);
        }
Beispiel #22
0
        /// <summary>
        /// Downloads the contents of a blob into a byte[]
        /// </summary>
        /// <param name="containerName">The blob's container</param>
        /// <param name="blobName">The name of the blob to download</param>
        /// <returns>Byte[] with the blob's contents</returns>
        private byte[] GetBlobAsByteArr(string containerName, string blobName)
        {
            CloudBlobContainer container = _blobClient.GetContainerReference(containerName);

            _blockBlob = container.GetBlockBlobReference(blobName);
            _blockBlob.FetchAttributes();

            long fileByteLength = _blockBlob.Properties.Length;

            byte[] fileContentsAsByteArr = new byte[fileByteLength];
            _blockBlob.DownloadToByteArray(fileContentsAsByteArr, 0);

            return(fileContentsAsByteArr);
        }
        public byte[] DownloadBlobAsByteArray(string containerName, string blobName)
        {
            // Create the CloudBlobClient that represents the Blob storage endpoint for the storage account.
            CloudBlobClient cloudBlobClient = new CloudBlobClient(blobURI, creds);

            // Create a container called 'quickstartblobs' and append a GUID value to it to make the name unique.
            CloudBlobContainer cloudBlobContainer = cloudBlobClient.GetContainerReference(containerName);
            CloudBlockBlob     cloudBlockBlob     = cloudBlobContainer.GetBlockBlobReference(blobName);

            cloudBlockBlob.FetchAttributes();
            byte[] results = new byte[cloudBlockBlob.Properties.Length];
            cloudBlockBlob.DownloadToByteArray(results, 0);
            return(results);
        }
Beispiel #24
0
        byte[] IAzureBlobContainer <byte[]> .Get(string objId)
        {
            CloudBlockBlob blob = this.container.GetBlockBlobReference(objId);

            try
            {
                byte[] downloadedBytes = new byte[0];
                blob.DownloadToByteArray(downloadedBytes, 0);
                return(downloadedBytes);
            }
            catch (StorageException)
            {
                return(null);
            }
        }
Beispiel #25
0
        /// <summary>
        /// Downloads the image.
        /// </summary>
        /// <param name="imageName">Name of the image.</param>
        /// <returns>System.Byte[].</returns>
        public byte[] DownloadImage(string imageName)
        {
            CloudBlockBlob blockBlob = container.GetBlockBlobReference(imageName);

            blockBlob.FetchAttributes();
            long fileByteLength = blockBlob.Properties.Length;

            byte[] fileContent = new byte[fileByteLength];
            for (int i = 0; i < fileByteLength; i++)
            {
                fileContent[i] = 0x20;
            }
            blockBlob.DownloadToByteArray(fileContent, 0);
            return(fileContent);
        }
        public byte[] ReadStreamFromBlob(string blobName)
        {
            CloudBlobContainer container = GetDocumentsContainer();
            CloudBlockBlob     blockBlob = container.GetBlockBlobReference(blobName);

            blockBlob.FetchAttributes();
            long fileByteLength = blockBlob.Properties.Length;

            byte[] fileContent = new byte[fileByteLength];
            for (int i = 0; i < fileByteLength; i++)
            {
                fileContent[i] = 0x20;
            }
            blockBlob.DownloadToByteArray(fileContent, 0);
            return(fileContent);
        }
Beispiel #27
0
        public ActionResult ArticleViewModel(int id)
        {
            Article          article          = db.Articles.Find(id);
            ArticleViewModel articleViewModel = GetArticleViewModel(article);

            IQueryable <UbicationPicture> ubicationPictures = from p in db.UbicationPictures
                                                              where p.UbicationId == article.UbicationId && !p.OutstandingPicture
                                                              select p;
            IQueryable <UbicationFeatureUbication> ubicationFeatureUbication = from u in db.UbicationFeaturesUbication
                                                                               where u.UbicationId == articleViewModel.Article.UbicationId
                                                                               select u;

            //var filesEF = from f in db.Archivos
            //              where f.ArticleId == id
            //              select f;
            ViewBag.Files             = "";
            ViewBag.ubicationPictures = ubicationPictures.ToList();
            ViewBag.TerrainFeatures   = new SelectList(db.TerrainFeatures, "TerrainFeatureId", "Description");
            ViewBag.HouseFeatures     = new SelectList(db.HouseFeatures, "HouseFeatureId", "Description");
            articleViewModel.Article.Ubication.UbicationFeaturesUbication = ubicationFeatureUbication.ToList();
            ViewBag.UbicationFeatures = new SelectList(db.UbicationFeatures, "UbicationFeatureId", "Description");
            var picture = db.ArticlePictures.Single(x => x.ArticleId == id && x.OutstandingPicture);

            if (picture != null)
            {
                string keys = CloudConfigurationManager.GetSetting("ConnectionBlob");
                CloudStorageAccount cuentaAlmacenamiento = CloudStorageAccount.Parse(keys);
                CloudBlobClient     clienteBlob          = cuentaAlmacenamiento.CreateCloudBlobClient();
                CloudBlobContainer  container            = clienteBlob.GetContainerReference("ubicationpictures");
                CloudBlockBlob      blob = container.GetBlockBlobReference(picture.Extension);
                blob.FetchAttributes();
                long   fileByteLength = blob.Properties.Length;
                byte[] myByteArray    = new byte[fileByteLength];
                blob.DownloadToByteArray(myByteArray, 0);

                if (!SharePictureExists(container, picture))
                {
                    CloudBlobContainer shareContainer = clienteBlob.GetContainerReference("shareimages");
                    CreateSharePicture(myByteArray, shareContainer, picture.Extension);
                }
            }



            return(PartialView("ArticleViewModel", articleViewModel));
        }
Beispiel #28
0
        public Byte[] ReadAllBytesAzure(string empresa, string azureblob, Guid id, string extension)
        {
            string myBlobContainerReferenceKey = azureblob + empresa;

            var StorageAccount = CloudStorageAccount.Parse(strCloudStorageAccount);

            CloudBlobClient    BlobClient = StorageAccount.CreateCloudBlobClient();
            CloudBlobContainer Content    = BlobClient.GetContainerReference(myBlobContainerReferenceKey);
            CloudBlockBlob     blockBlob  = Content.GetBlockBlobReference(string.Format("{0}{1}", id, extension));

            blockBlob.FetchAttributes();
            long fileByteLength = blockBlob.Properties.Length;

            Byte[] myByteArray = new Byte[fileByteLength];
            blockBlob.DownloadToByteArray(myByteArray, 0);

            return(myByteArray);
        }
Beispiel #29
0
        private object GetData(CloudBlockBlob blob, DownloadDataType downloadDataType)
        {
            switch (downloadDataType)
            {
            case DownloadDataType.Text:
                return(blob.DownloadText());

            case DownloadDataType.ByteArray:
                var document = new byte[blob.Properties.Length];

                blob.DownloadToByteArray(document, 0);

                return(document);

            default:
                throw new ArgumentOutOfRangeException("downloadDataType");
            }
        }
Beispiel #30
0
        public static byte[] GetFileContent(string fileName)
        {
            fileName = String.IsNullOrEmpty(fileName) ? "office-1356793_1280.png" : fileName;
            CloudBlobContainer container = GetBlobContainer("imagecontainer");
            CloudBlockBlob     blockBlob = container.GetBlockBlobReference(fileName);

            blockBlob.FetchAttributes();
            long fileByteLength = blockBlob.Properties.Length;

            byte[] fileContent = new byte[fileByteLength];
            for (int i = 0; i < fileByteLength; i++)
            {
                fileContent[i] = 0x20;
            }

            blockBlob.DownloadToByteArray(fileContent, 0);
            return(fileContent);
        }