Skip to content

Instantly share code, notes, and snippets.

@glglak
Created June 3, 2018 12:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save glglak/c158711e837d4989f376798dc0590c0e to your computer and use it in GitHub Desktop.
Save glglak/c158711e837d4989f376798dc0590c0e to your computer and use it in GitHub Desktop.
public async Task<byte[]> GetImageAsByteArray(string imageFilePath)
{
CloudStorageAccount cloudStorageAccount = CloudStorageAccount.Parse(connectionStorage);
CloudBlobClient cloudBlobClient = cloudStorageAccount.CreateCloudBlobClient();
CloudBlobContainer cloudBlobContainer = cloudBlobClient.GetContainerReference (containerReferrence);
CloudBlob cloudBlob = cloudBlobContainer.GetBlobReference(new CloudBlockBlob(new Uri(imageFilePath)).Name);
await cloudBlob.FetchAttributesAsync();
long fileByteLength = cloudBlob.Properties.Length;
Byte[] myByteArray = new Byte[fileByteLength];
await cloudBlob.DownloadToByteArrayAsync(myByteArray, 0);
return myByteArray;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment