Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
432 views
in Technique[技术] by (71.8m points)

javascript - How to check existence of a file in Firebase Storage without logging an error?

Basically, I want to check if a file exists on a specific location on FB Storage If so then, do some Stuff else some other stuff needs to be executed.

so far I have tried this

const profile_pic = firebase.storageRef
        .child(`profile_pics/${uid}/}`)
        .getDownloadURL()
        .then((url) => {
          setProfileImage(url);
        })
        .catch((err) => {
          // show Default userPic    
          console.log("err >> ", err);
        });

This code Resembles the answer here

This Code works Fine BUT BUT BUT It still logs Error on the console. enter image description here

All I'm Looking for is the best way to get it done without logging Error On console. Any help is Appreciated! Thanks.

question from:https://stackoverflow.com/questions/65874675/how-to-check-existence-of-a-file-in-firebase-storage-without-logging-an-error

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
const profile_pic = firebase.storageRef
        .child(`profile_pics/${uid}/}`)
        .getDownloadURL()
        .addOnSuccessListener(new OnSuccessListener(){

        {
          setProfileImage(url);
        })
          .catch((err) => {   
           console.log("err >> ", err);
        }

        });

Try this


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...