第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會有你想問的

如何在Firebase應(yīng)用程序中獲得云存儲中所有文件的列表?

如何在Firebase應(yīng)用程序中獲得云存儲中所有文件的列表?

白板的微信 2019-06-05 12:43:45
如何在Firebase應(yīng)用程序中獲得云存儲中所有文件的列表?我正在上傳圖片,一切都很好,但我有100張照片,我想在我的View,當(dāng)我在文件夾中獲得圖像的完整列表時(shí),我找不到用于這項(xiàng)工作的任何API。
查看完整描述

3 回答

?
繁花如伊

TA貢獻(xiàn)2012條經(jīng)驗(yàn) 獲得超12個(gè)贊

加上火基云函數(shù)以及Firebase與GoogleCloud的更深層次的集成,這已經(jīng)成為可能。

使用云函數(shù),您可以使用GoogleCloudNode包來完成史詩云存儲操作。下面是一個(gè)從CloudStorage獲取所有文件URL到數(shù)組中的示例。這個(gè)功能每次被保存到Google云存儲時(shí)都會被觸發(fā)。

附注1這是一個(gè)計(jì)算上相當(dāng)昂貴的操作,因?yàn)樗仨毐闅v桶/文件夾中的所有文件。

附注2:我寫這個(gè)只是作為一個(gè)例子,沒有把很多細(xì)節(jié)寫成承諾等等。只是想給個(gè)主意。

const functions = require('firebase-functions');
const gcs = require('@google-cloud/storage')();

// let's trigger this function with a file upload to google cloud storage

exports.fileUploaded = functions.storage.object().onChange(event => {

  const object = event.data; // the object that was just uploaded
  const bucket = gcs.bucket(object.bucket);
  const signedUrlConfig = { action: 'read', expires: '03-17-2025' }; // this is a signed url configuration object

  var fileURLs = []; // array to hold all file urls 

  // this is just for the sake of this example. Ideally you should get the path from the object that is uploaded :)
  const folderPath = "a/path/you/want/its/folder/size/calculated";

  bucket.getFiles({ prefix: folderPath }, function(err, files) {
    // files = array of file objects
    // not the contents of these files, we're not downloading the files. 

    files.forEach(function(file) {
      file.getSignedUrl(signedUrlConfig, function(err, fileURL) {
        console.log(fileURL);
        fileURLs.push(fileURL);
      });
    });

  });

});

我希望這能給你一個(gè)大致的想法。要獲得更好的云功能示例,請查看Google的Gizubrepo充滿了用于FireBase的云功能示例..也檢查他們的GoogleCloudNodeAPI文檔


查看完整回答
反對 回復(fù) 2019-06-05
  • 3 回答
  • 0 關(guān)注
  • 753 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號