firebase-admin.storage package

Cloud Storage for Firebase。

函式

函式 說明
getDownloadURL(檔案) 取得指定 File 的下載網址。
getStorage(應用程式) 取得預設應用程式或特定應用程式的 Storage 服務。不用引數即可呼叫 getStorage(),藉此存取預設應用程式的 Storage 服務,也可呼叫 getStorage(app) 以存取與特定應用程式相關聯的 Storage 服務。

等級

類別 說明
儲存空間 預設的 Storage 服務 (如未提供應用程式),或與所提供應用程式相關聯的 Storage 服務。

getDownloadURL(檔案)

取得指定 File 的下載網址。

簽名:

export declare function getDownloadURL(file: File): Promise<string>;

參數

參數 類型 說明
檔案 檔案

傳回:

Promise<string>

範例

// Get the downloadUrl for a given file ref
const storage = getStorage();
const myRef = ref(storage, 'images/mountains.jpg');
const downloadUrl = await getDownloadURL(myRef);

getStorage(應用程式)

取得預設應用程式或特定應用程式的 Storage 服務。

呼叫 getStorage() 時無需引數,即可存取預設應用程式的 Storage 服務,或做為 getStorage(app) 存取與特定應用程式相關聯的 Storage 服務。

簽名:

export declare function getStorage(app?: App): Storage;

參數

參數 類型 說明
app 應用程式

傳回:

儲存空間

範例 1

// Get the Storage service for the default app
const defaultStorage = getStorage();

範例 2

// Get the Storage service for a given app
const otherStorage = getStorage(otherApp);