I wrote a trigger function, when triggered, it will delete a file from storage with a certain name. Problem is here, I do not know the extension of the file. It could be either .png or .jpeg. I tried to write some code to delete the image without regard to file extension, but It does not work. It throws No such object error.
exports.onUserDeletion = functions.auth.user().onDelete((user) => {
const userid = user.uid
const filePath = `user_photo/${userid}.{extension}`
const file = bucket.file(filePath)
return file.delete()
})
Is there any way to achieve this? Or any workaround where I perfom this deletion without knowing the extension in beforehand?