如何从Google-Cloud存储生成DownloadUrl(我来自firebase)

时间:2017-10-20 07:17:29

标签: firebase google-cloud-storage firebase-storage

试图在google-cloud中找出一些在firebase中看似微不足道的东西。

好像你是在为HTML创建一个node.js应用程序(我实际上通过Unity与它交谈,但它是桌面应用程序)你无法使用firebase-storage由于一些奇怪的原因,你必须使用google-cloud,即使firebase-admin工具也使用云存储从这里进行存储。

然而,我得到了它的工作,我将文件上传到firebase存储;但是,问题出在firebase中,你可以指定一个特定的文件,然后执行storage()。ref()。child(filelocation).GetDownloadURL():这会生成一个可以公开使用的设置时间的唯一url ,无需向所有匿名用户提供读取权限。

我做了一些研究,我需要实现一个名为GS UTIL的东西,以便生成我自己的特殊网址,但它太复杂了(我是整个服务器的新手),我不会这样做。甚至知道从哪里开始让我的节点服务器工作。

任何指针?我真的被困在这里了。

-------如果有人感兴趣,这就是我试图做的高水平-----

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 个答案:

答案 0 :(得分:0)

想出来:



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();
                        }
                    });