How can I reference a GCP cloud storage object, from the firebase download link, using the Admin SDK
How can I reference a GCP cloud storage object, from the firebase download link, using the Admin SDK
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()
.
refFromUrl()
Is there a simple way to do this? The context is - I want to delete the object for the given download link.
1 Answer
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.
Thanks for contributing an answer to Stack Overflow!
But avoid …
To learn more, see our tips on writing great answers.
Required, but never shown
Required, but never shown
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Yes - that is a solution I've considered.
– dwjohnston
Sep 7 '18 at 4:10