【发布时间】:2019-07-04 08:37:00
【问题描述】:
我正在尝试从名称设置为用户的用户 ID 的 firebase 下载个人资料图片。我正在使用 glide 库下载图像,但我收到 StorageException: StorageException has occurred. Object does not exist at location. 错误。
这是我的代码
String uid = user.getUid();
storageReference.child("ProfilePictures").child(uid).getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
// Got the download URL for 'users/me/profile.png'
Log.d("TAG" , "URI = "+uri);
GlideApp.with(context).load(uri).into(profilepic);
//profilepic.setImageURI(uri);
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception exception) {
// Handle any errors
Toast.makeText(getApplicationContext(), "Error getting Profile Picture", Toast.LENGTH_LONG).show();
}
});
}
@Override
public void onCancelled(DatabaseError databaseError) {}
});
存储参考声明
StorageReference storageReference;
storageReference = FirebaseStorage.getInstance().getReference();
【问题讨论】:
-
您是否收到此日志
Log.d("TAG" , "URI = "+uri);? -
没有应用崩溃
-
试试
.child(uid + ".jpg") -
尝试使用
child()一次,像这样:.child("ProfilePictures/" + uid + ".jpg")。 -
对不起,我是私人的,但我能问一下你为 Firebase 存储设置了什么规则吗?
标签: java android firebase firebase-storage