I am developing android application where a user clicks image, it gets stored in firebase, cloud functions process this image and stores the output back in the firebase in t
This is how I am currently checking to see if the file Exists.
The this.auth.user$ pulls an observable that displays the current user's data from the FireStore database. I store the FileStorage profile image reference in the FireStore database.
I then use the File Path in the user's data and use it for the FileStorage reference.
Now use the observable and check to see if the downloadURL length is less than or equal to 0.
If it is indeed greater than zero then the file exists; then go do something. Else do something else.
ngOnInit() {
this.userSubscription = this.auth.user$.subscribe((x) => {
console.log(x);
this.userUID = x.userId;
this.userPhotoRef = x.appPhotoRef;
this.userDownloadURL = x.appPhotoURL;
});
const storageRef = this.storage.ref(this.userPhotoRef);
console.log(storageRef);
if (storageRef.getDownloadURL.length <= 0) {
console.log('File Does not Exist');
} else {
console.log('File Exists');
}
}