2017-10-20 175 views
1

只是試圖找出在firebase中,谷歌雲中看起來微不足道的東西。如何從Google-Cloud存儲生成DownloadUrl(我來自Firebase)

看起來好像你是否爲HTML創建了一個node.js應用程序(我實際上是通過Unity與它交談,但它是一個桌面應用程序),由於某些奇怪的原因你不能使用Firebase存儲,您必須使用谷歌雲,即使是Firebase管理工具也可以使用雲存儲從這裏進行存儲。不過,我得到它的工作,我上傳的文件到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). 

回答

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