Answer the question
In order to leave comments, you need to log in
Why do I get an exception when getting the url after saving the image in FirebaseStorage?
Good afternoon. Help me to understand. You need to put an image in FirebaseStorage and then put the url to this image in the database. Wrote a method:
public void updateProfileImage(Uri resultUri) {
storage.getReference().child(StorageConstants.PROFILE_IMAGES_DIR_NAME).child(getCurrentFirebaseUser().getUid()+".jpg").putFile(resultUri)
.addOnCompleteListener(task -> {
if (task.isSuccessful()){
db.collection(UserCollection.COLLECTION_NAME).document(getCurrentFirebaseUser().getUid())
.update(UserCollection.UserDocument.PROFILE_FIELD, task.getResult().getStorage().getDownloadUrl())
.addOnSuccessListener(aVoid -> {
status.postValue(Status.IMAGE_UPDATED);
updateUser();
})
.addOnFailureListener(e -> status.postValue(Status.SOMETHING_WRONG));
}else{
status.postValue(Status.SOMETHING_WRONG);
}
});
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question