0

I'm trying to retrieve video URIs from objects in Google Firebase to display in a Flatlist. If the video at that URI was deleted, I want to catch and remove that item from the Flatlist.

The Image object that comes with ReactNative throws an error when the URI location doesn't have an image, but the Video component from Expo doesn't.

Is there a way to check URIs in JS?
Thank you in advance!

ece321
  • 3
  • 3
  • I ended up finding a workaround elsewhere so I don't have to read from the database such an insane amount. But your solution does work for the question I asked. Thank you! – ece321 Oct 12 '20 at 13:08

1 Answers1

0

There is no API in the Firebase SDK to check whether a file exists in Cloud Storage. It's actually an interesting idea, so I'd recommend you file a feature request.

In the meantime I can think of two options:

  1. Use the list() or listAll() calls to check what files do exist. If your file is not in the results, it doesn't exist. The main concern here is that if the list of files is long, it might actually be worse off than trying to download the file anyway.

  2. Use the Node.js SDK on a server (or in Cloud Functions) to check if the file exists, and call that from your application code.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807