Eindbaas
Eindbaas

Reputation: 985

How to link a Firebase Storage file to a Firebase Database entry?

I have users uploading files, and a Cloud Function responding by adding the uploaded file to the database, and planned on using the following path:

/files/{user-id}/{filename}

The reasoning being that if a file gets deleted, i can in the Cloud Function immediately get the reference to the database-reference.

However, i am not allowed to use certain characters in db-paths that are allowed in filenames (most specifically, a dot). How should this be set up, so that for a removed Storage-file I can immediately get the correct Database-path?

Upvotes: 0

Views: 998

Answers (1)

Doug Stevenson
Doug Stevenson

Reputation: 317760

You could push() the path under /files/{uid} to create the entry, then orderByValue().equalTo(x) to find the entry later for deletion. This way, you won't have to worry about the contents of the file name.

Upvotes: 1

Related Questions