-1

My question is similar to this: Firebase web: Storage Location from Download URL

I'm writing a firebase function where i need storage location. Right now i have download url:

https://firebasestorage.googleapis.com/v0/b/dxxxxxxxxx.com/o/videosvideo%3A67423?alt=media&token=acxxxxxxxxxxxxxxxxx

Is there a way to get Storage location like this:

gs://dexxxxxxxxxxxxxx.com/videosvideo:67423

The answer given is to do:

const downloadUrl = "https://firestorage.googleapis...";
const gsUrl = firebase.storage().refFromUrl(downloadUrl).toString();

However, the context I'm doing this, is as a Firebase Function - so I need to use the Admin SDK.

The Admin SDK Storage directly references the the GCP Storage Buckets, which don't have refFromUrl().

Is there a simple way to do this? The context is - I want to delete the object for the given download link.

dwjohnston
  • 11,163
  • 32
  • 99
  • 194

1 Answers1

1

I don't think there is a server side API that's going to do what you want. I'd recommend storing not just the download URL in your database, but also the path to the file in storage. That way, the server can deal with the file easily through the Admin SDK.

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441