总而言之,我想在Firebase中为每个用户存储和检索 Profiles 图片 . 我正在尝试使用FirebaseUI和Glide从Firebase检索图像(如here所述) .
它非常适合我想要实现的目标,但我希望在用户没有上传自己的 Profiles 图片时(Firebase存储中没有图片时)处理这种情况 . 遗憾的是,我无法找到如何检查Firebase存储中是否存在此类文件 . 有没有人知道如何检查是否有文件 profile.jpg
(在Firebase存储中)以下代码?
StorageReference storageRef = storageReference.child("profile.jpg");
ImageView imageView = profilePicture;
// Load the image using Glide
Glide.with(context /* context */)
.using(new FirebaseImageLoader())
.load(storageRef)
.into(imageView);
1 回答
要显示默认图片,如果firebase上没有'profile.jpg',则在较新的v4 Glide中,您可以使用RequestOptions,如下所示:
Glide v3的原始答案
使用错误方法: