从 firebase 存储中检索图像并在应用程序中查看图像 [英] retrieve image from firebase storage and view the image in the app
本文介绍了从 firebase 存储中检索图像并在应用程序中查看图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用 firebase 存储来存储用户的个人资料图像
im using firebase storage to store a profile image of the users
上传效果很好,
当我想将图像作为图像源查看时,我使用以下代码:
when i want to view the image as an imagesource i use this code:
public async Task<string> LoadImages()
{
var stroageImage = await new FirebaseStorage("foodymood-ba7aa.appspot.com")
.Child("Users/" + Settings.LastUserID)
.Child("ProfileImage.jpg")
.GetDownloadUrlAsync();
string imgurl = stroageImage;
return imgurl;
}
它返回下载网址:
现在我不知道如何使用这个网址来查看图片..
now i dont know how to use this url for viewing the image..
推荐答案
用这个代码修复:
public async Task<ImageSource> LoadImages()
{
var webClient = new WebClient();
var stroageImage = await new FirebaseStorage("foodymood-ba7aa.appspot.com")
.Child("Users/" + Settings.LastUserID)
.Child("ProfileImage.jpg")
.GetDownloadUrlAsync();
string imgurl = stroageImage;
byte[] imgBytes = webClient.DownloadData(imgurl);
//string img = Convert.ToBase64String(imgBytes);
var img = ImageSource.FromStream(() => new MemoryStream(imgBytes));
return img;
}
这篇关于从 firebase 存储中检索图像并在应用程序中查看图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文