简体   繁体   中英

How do I save an image url from Firebase Storage to Firebase realtime data base, the image from my device

I have been trying to save the url to the firebase realtime database here is my code

Uri  uri = data.getData();
        StorageReference filePath = 
mStorage.child("Photos").child(currentFirebaseUser.getUid());

        filePath.putFile(uri).addOnSuccessListener(new 
OnSuccessListener<UploadTask.TaskSnapshot>() {
            @Override
            public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
                Toast.makeText(ManageActivity.this, "Image upload 
 successful",Toast.LENGTH_LONG).show();
                progressDialog.dismiss();

                profile_image_url = taskSnapshot.getDownloadUrl();
                driver.child("profile image").setValue(profile_image_url);

the logcat shows that its a stack over flow error, here is the logcat:

FATAL EXCEPTION: main
    Process: com.example.user.drivergeofire, PID: 6758
    java.lang.StackOverflowError
    at java.util.HashMap$ValueIterator.<init>(HashMap.java:836)
    at java.util.HashMap$ValueIterator.<init>(HashMap.java:836)
    at java.util.HashMap.newValueIterator(HashMap.java:908)
    at java.util.HashMap$Values.iterator(HashMap.java:936)
    at com.google.android.gms.internal.zh.zzas(Unknown Source)
    at com.google.android.gms.internal.zg.zzao(Unknown Source)

my research on StackOverflow erros state that it is cause by having may views, I don't have any there. Your assistance will be veery much appreciated

要从保存的文件中获取周二URL,请使用:

mStorage.child("Photos").child(currentFirebaseUser.getUid()).getDownloadUrl().getResult(); 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM