Created
June 13, 2019 19:55
-
-
Save codeboy5/86a7a7099b6d90420b7ea43454f466eb to your computer and use it in GitHub Desktop.
Script To Fetch Images From Firebase Storage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Your web app's Firebase configuration | |
var firebaseConfig = { | |
apiKey: "", | |
authDomain: "", | |
databaseURL: "", | |
projectId: "", | |
storageBucket: "", | |
messagingSenderId: "", | |
appId: "" | |
}; | |
// Initialize Firebase | |
firebase.initializeApp(firebaseConfig); | |
var storage = firebase.storage(); | |
var storageRef = storage.ref(); | |
//! List All Albums | |
storageRef | |
.listAll() | |
.then(result => { | |
result.prefixes.forEach(element => { | |
displayAlbum(storageRef.child(`${element.fullPath}`)); | |
// console.log(element.fullPath); | |
}); | |
}) | |
.catch(err => console.log(err)); | |
// List All Photos In That Album | |
function displayAlbum(albumRef) { | |
albumRef | |
.listAll() | |
.then(result => { | |
result.items.forEach(element => { | |
element | |
.getDownloadURL() | |
.then(url => console.log(url)) | |
.catch(err => console.log("Error In Getting")); | |
}); | |
}) | |
.catch(err => console.log(err)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment