'When trying to save the URL from the storage to RealtimeDatabase I get a DatabaseException Error
I am trying to store an image url which I get by uploading it to a FirebaseStorage in a RealtimeDatabase. The former works without any problems. The image is created in the storage. However, in the OnSuccessListener I cannot save the URL in realtime. Then I get the following error:
com.google.firebase.database.DatabaseException: Failed to parse node with class class com.bkoubik.niceplace.AddNewPlace$4$1$1
AddNewPlace.java class:
StorageReference storageRef = FirebaseStorage.getInstance().getReference();
StorageReference mountainsRef = storageRef.child("images/"+ UUID.randomUUID() +".jpg");
Uri uploadUri = Uri.fromFile(new File(imageUri.toString()));
mountainsRef.putFile(uploadUri).addOnSuccessListener(new
OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
bar.setProgress(0);
status.setText("100 %");
mountainsRef.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
DatabaseReference ref = FirebaseDatabase.getInstance().getReference();
//UploadUriForPlace up = new UploadUriForPlace(uri.toString());
String placeId = ref.push().getKey();
ref.child(new Date().toString()).setValue(uri.toString(), new OnSuccessListener() {
@Override
public void onSuccess(Object o) {
Toast.makeText(AddNewPlace.this,"Ist oben, danke!",Toast.LENGTH_LONG);
}
});
}
});
}
});
Uri is not empty:
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

