Currently I'm using getDownloadURL()
and error handling like this
const storage = getStorage();
async checkIfFileExists(filePath) {
const docRef = ref(storage, filePath)
try {
await getDownloadURL(docRef)
return true
} catch (error) {
return false
}
}
which works, but kind of feels like a workaround. So I'm wondering if this is the way to go or if there's a better alternative. Maybe I'm missing a build in way to directly request the existence? (with 'Web v9' options)
CodePudding user response:
There isn't any direct way like exists()
to check existence of a file. The V9 SDK just has a new API surface designed to facilitate tree-shaking but most of the functionality remains same.