[英]How to download non-image file(pdf,pptx,docx) from FirebaseStorage to internal storage of device in Xamarin.Forms?
[英]How to show images from device storage in Xamarin.Forms?
我需要将图像的Source
属性设置为用户从画廊或相机(使用Plugin.Media)中选择图像后返回的路径,该路径如下所示:
/storage/emulated/0/Android/data/com.company.myApp/files/Pictures/temp/Screenshot_20181225-134128_6.jpg
我试过了
ImageSource.FromUri(new Uri(file.FilePath, UriKind.RelativeOrAbsolute));
但是图像什么也没显示
您可以创建MediaFile对象,例如
public MediaFile AttachedImage;
并将捕获的图像存储到其中,以便解决以下问题,将引发此异常:System.ObjectDisposedException:无法访问已处置的对象。 对象名称:'流已关闭 。 您可以随时从该对象获取图像流,例如,
img.Source = AttachedImage.GetStream().
它一定会解决您的问题。
Media Plugin返回带有路径的文件。 您必须使用此文件:
image.Source = ImageSource.FromStream(() =>
{
var stream = file.GetStream();
return stream;
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.