'How to upload file with content to Firebase Storage Bucket from Firebase Function

I have been following the documentation on how to upload files Google Documentation

So I have the following:

await admin.storage().bucket().file("test.txt").save("Some text");

After this I can see my file successfully uploaded to my bucket:

enter image description here

but whenever I try to open it, it gives me an undefined URL:

https://console.firebase.google.com/project/my-project/storage/my-project.appspot.com/undefined

Which causes a redirect and I can't access the file from the browser or programatically from my cloud function I have also tried to make sure the file is public by running this right after the creation of the file:

await admin.storage().bucket().file("test.txt").makePublic();

Maybe I'm missing something silly here but I can't spot it

Thanks for reading me :)

UPDATE:

There is no problem with the programatic access, also the file can be accessed from GCP Console but the problem opening the file from Firebase console and getting that undefined URL persists



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source