Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
433 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 Reply

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...