0

I'd like to get an anonymously downloadable link of a file in Google Cloud storage from firebase functions.

From JS SDK, you can get a permanently downloadable link via

const ref = storageRef.child('images/stars.jpg');
const url = await ref.getDownloadURL()

[1]. Is it possible to do the same thing from functions using firebase-admin or firebase/storage? I've found only a signed url[2], which is valid for up to 7 days.

[1] https://firebase.google.com/docs/storage/web/download-files
[2] https://cloud.google.com/storage/docs/access-control/signed-urls

Watanabe.N
  • 1,549
  • 1
  • 14
  • 37
  • See https://stackoverflow.com/questions/42956250/get-download-url-from-file-uploaded-with-cloud-functions-for-firebase, specifically this answer https://stackoverflow.com/a/43764656 – Frank van Puffelen Nov 12 '21 at 15:06

1 Answers1

2

There is no SDK support for this. There is an open feature request:

https://github.com/firebase/firebase-admin-node/issues/1352

Which references a lengthy issue from the Google Cloud SDK (for which firebase-admin is just a wrapper):

https://github.com/googleapis/nodejs-storage/issues/697

Once you read through all that, you'll understand that this is a long-running feature request that probably won't be supported any time soon.

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
  • I see the situation. Thank you so much for terminating my endless search on Google and GitHub Issues. I'll handle from JS SDK. – Watanabe.N Nov 12 '21 at 15:16
  • Hi Doug - is there anything wrong with just making the Cloud Storage bucket public, and referencing the public URL directly using the format (https://storage.googleapis.com/${bucket.name}/${file.name})? This seems to be the simplest solution for public data that does not require security authorization, but I am curious if there is a reason not to use it. – Redneys Nov 17 '21 at 22:59