【发布时间】:2017-08-10 23:46:44
【问题描述】:
总而言之,我想在 Firebase 中为每个用户存储和检索个人资料图片。我正在尝试使用 FirebaseUI 和 Glide 从 Firebase 检索图像(如 here 所述)。
它非常适合我想要实现的目标,但我想处理用户没有上传自己的个人资料图片(当 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);
【问题讨论】:
-
当您说“处理用户没有上传自己的头像的情况”时,您想调用具有业务逻辑的特定方法或仅在配置文件
ImageView中显示占位符/错误图标? -
我想为所有未上传自己的用户的个人资料图片提供默认图片。因此,“句柄”的意思是,如果 Firebase 存储中没有图片,我想显示默认的。
标签: android firebase firebase-storage android-glide firebaseui