I am working with Xamarin forms and I've stored an image in Azure blob storage which I'd like to download on page load and put into an image view, as of now I have this code:
using(var fileStream = imageStore.GetStream())
{
blockBlob.DownloadToStreamAsync(fileStream);
}
This code should download the image into a file stream (Please let me know if I'm wrong) but then I need to get the image out of that file stream and set it as the image view source, but I don't know how to do that.
You can directly convert the stream to an Image.Source
via the static method ImageSource.FromStream
:
using (var fileStream = new MemoryStream())
{
await blockBlob.DownloadToStreamAsync(fileStream);
image.Source = ImageSource.FromStream(() => fileStream);
}
Note: DownloadToStreamAsync
returns a Task
, so await
it...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With