1
votes

Just trying to figure out something that seemed trivial in firebase, in google-cloud.

It seems as though if you're making a node.js app for HTML (i'm talking to it through Unity actually, but it's a desktop application) you can't use firebase-storage for some odd reason, you have to use google-cloud, even the firebase-admin tools use the cloud storage to do storage from here.

Nevertheless, i got it working, i am uploading the files to the firebase storage; however, the problem is in firebase, you could specify a specific file, and then do storage().ref().child(filelocation).GetDownloadURL(): this would generate a unique url for some set time that can be used publicly, without having to give out access to read to all anonymous users.

I did some research and i need to implement something called GS UTIL in order to generate my own special urls, but it's so damn complicated (im a newbie to this whole server stuff), i don't even know where to start to get this working in my node server.

Any pointers? I'm really stuck here.

-------if anyones interested, this is what im trying to do high level-----

I'm sending 3d model data to node app from Unity
the node app is publishing this model on sketchfab
then it puts the model data onto my own storage, along with some additional data specially made for my app
after it gets signed to storage, it gets saved to my Firebase DB in my global model database
to be accessed later, by users, to try to get the downloadURL of this storage file and send them all back to Unity users(s)
I would just download the files into my node app, but i wanna reduce any server load, it's supposed to be just a middleman between Unity and Firebase
(i would've done it straight from Unity, but apparently firebase isn't for desktop windows apps).
1

1 Answers

0
votes

Figured it out:

var firebase_admin = require("firebase-admin");
var storage = firebase_admin.storage();
var bucket = storage.bucket();

bucket.file(childSnapshot.val().modelLink).getSignedUrl({
                        action: 'read',
                        expires: expDate
                    },function(err,url){
                        if(err){
                            reject(err);
                        }
                        else{
                            finalData.ModelDownloadLink = url;
                            console.log("Download model DL url: " + url);
                            resolve();
                        }
                    });