Created
February 9, 2020 09:41
-
-
Save bcnzer/e36462c8afad11e95af6dff1502faba9 to your computer and use it in GitHub Desktop.
Example of using the getDownloadURL method to check for a file's existance
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
// Using promise | |
const listRef = storage | |
.ref('screenshots/abc123.png') | |
.getDownloadURL() | |
.then((response) => { | |
// Found it. Do whatever | |
}) | |
.catch((err) => { | |
// Didn't exist... or some other error | |
}) | |
// Using async/await | |
const ref = storageRef.ref('screenshots/abc123.png') | |
try { | |
await ref.getDownloadURL() | |
// Do whatever | |
} catch(err) { | |
// Doesn't exist... or potentially some other error | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment