Can't access uploaded files through Firebase storage on web - firebase

I'm trying to access/download files that have been uploaded to Firebase storage but I can't figure out how to. Some of the files have a create new access token button under the storage location which gives me a link to the file on the web. Unfortunately, this is only a few files and seems to only be ones uploaded from localhost?
I can't find any reference to this on the documentation, this should be achievable through the Firebase dashboard?
I've tried setting the access rules to allow reads in all cases which hasn't helped.
Thanks

In general, you're supposed to use getDownloadURL(), as shown in the documentation, from within your web or mobile app to generate a download URL for use within your app. Typically, the console is only used to revoke the tokens that enable to download of each file through that URL.
If that's not specifically what you're trying to do, perhaps you want to read up on other was to make data public in Cloud Storage. The Firebase console is not really the best mechanism to manage downloadable content.

Related

Writing to Files in Firebase Storage?

I have a html file inside my Firebase storage(say hello.html).I have an html content
<div>Hello world</div>
I need to write this content to the above hello.html in the storage.How to do this using Firebase Cloud Functions??
For you to be able to perform that, it will depend on the way that your file is uploaded on the Firebase and how you would like to edit them.
Considering that, I would recommend you to take a look at the below links, to verify the options that are available for you to edit.
Using Firebase Cloud Functions to Update Hosted File
Tutorial: How to upload files using Firebase
Read value/content of a file from Firebase Storage
Let me know if the information helped you!

Firebase Functions - generate and host static webpage

I'm using Firebase Cloud Functions to generate an HTML file and now I'd like to host it together with related assets (js, css, fonts etc.) but without success.
I call the function, it generates the file properly and puts it in Firebase Storage together with js/css/other assets. Now I would like to return a URL of the index.html file so that the user can access it in the browser and the .html page will have access to the assets. Unfortunately the generated URL enforces download but I'm pretty sure that even if I managed it somehow, it won't be able to access asset files.
I know it's possible on AWS (S3 bucket) but can I do it on Firebase? Firebase Hosting doesn't seem to be the right solution in that case, does it?
Don't save it to Storage, that's a bad use case for this scenario. Instead, save it to Hosting:
https://firebase.google.com/docs/hosting/
Also, you can consider serving the content directly from the cloud function, probably there's no need to create a static version first.

Using Firebase Cloud Functions to Update Hosted File

I am building a site that is using Angular 4, Firebase, and Firebase Cloud Functions. What I am looking to do is when certain data is added to the database I want to add, remove, or update something in an RSS feed, sitemap, and JSON feed which are files hosted with Firebase Hosting.
Any suggestions on how to accomplish this or an alternative if it is not possible without manual updates and redeploys of the project?
There is currently no way to publish a new (or update a) file to Firebase Hosting based on a database (or other dynamic) trigger.
What is possible is to map a Cloud Function to a path on your site (e.g. /sitemap or /feed), generate the HTML in that Cloud Function, and then set caching headers on the result.

Firebase Storage gs url to http

I downloaded a Unity project that use images stored in Firebase server using the following link:
https://zplayer360-86b30.firebaseapp.com
Now I want to reproduce this with my own file. I created a Firebase project using Firebase Console, uploaded manually the images, but now I click "copy folder url" button and it provide me only this link:
gs://insidehome-29c9e.appspot.com/
I need a free HTTP public link.
How can I obtain this?
When you upload a file to Firebase Storage, it automatically gets:
a Google Storage URL (starting with gs://), which you can use to access the file through the Firebase Storage SDK and the Google Storage API.
a download URL (starting with https://), which is a publicly-readable-but-non-guessable URL that you can use to download the URL with regular HTTP clients
What you're looking for is the second URL, which you can find in the Firebase Storage console when you select a file:
At the bottom right you can see the download URLs for the file. One of these is auto-created when you upload the file, but you can create more of them or revoke existing ones.
I am not entirely sure what you mean by "free" URL. The link is publicly readable, but downloads will count against your Firebase Storage download quota of course.
If there are no rules on Firebase storage. You are not protected.
Then it's publicly-readable-and-guessable, One can convert gs:// URL to https:// to download any file without Google SDK's.
https://firebasestorage.googleapis.com/v0/b/[projectID].appspot.com/o/[folderName]%2F[fileName]
Google Storage URL
gs://invitepeople-5d38c.appspot.com/profilePhotos/profile_1.jpg
Https downloadable URL
https://firebasestorage.googleapis.com/v0/b/invitepeople-5d38c.appspot.com/o/profilePhotos%2Fprofile_1.jpg?alt=media
Don't guess profile_2.jpg :)

How to r/w between Google Spreadsheet and Firebase Storage?

I have a Google spreadsheet with a list of image filenames in rows (e.g. tree01, tree02, car01, building01, etc.) and I have a Firebase Storage with a list of image files with the same name (e.g. tree01, tree02, car01, building01, etc.).
How can I get the filename in spreadsheet? Then use the filename to get a download URL in Firebase storage and then put the download URL back to the spreadsheet?
I know how to use Google App Script to r/w with spreadsheet. I have searched online that using Google Web App, using "Web Server for Chrome" and get the download URL from Firebase Storage, but I don't know how to put them together. Please help.
I solve my problem after studying some links. And following up with a useful links for my case.
passing data between google app script (.gs) and google web app (.html)
(https://developers.google.com/apps-script/guides/html/communication)
firebase storage tutorial for web app
(https://github.com/firebase/quickstart-js)
firebase database tutorial for google app script
(https://sites.google.com/site/scriptsexamples/new-connectors-to-google-services/firebase)
I can now communicate between firebase-storage, firebase-database and google spreadsheet

Resources