Cloud Storage for Firebase.
Functions
| Function | Description |
|---|---|
| getDownloadURL(file) | Gets the download URL for the given File. |
| getStorage(app) | Gets the service for the default app or a given app.getStorage() can be called with no arguments to access the default app's Storage service or as getStorage(app) to access the Storage service associated with a specific app. |
Classes
| Class | Description |
|---|---|
| FirebaseStorageError | Firebase Storage error code structure. This extends FirebaseError. |
| Storage_2 | The default Storage service if no app is provided or the Storage service associated with the provided app. |
Variables
| Variable | Description |
|---|---|
| StorageErrorCode | The constant mapping for valid Storage client error codes. |
Type Aliases
| Type Alias | Description |
|---|---|
| StorageErrorCode | The type definition for valid Storage client error codes. |
getDownloadURL(file)
Gets the download URL for the given File.
Signature:
export declare function getDownloadURL(file: File): Promise<string>;
Parameters
| Parameter | Type | Description |
|---|---|---|
| file | File |
Returns:
Promise<string>
Example
// Get the downloadUrl for a given file ref
const storage = getStorage();
const myRef = ref(storage, 'images/mountains.jpg');
const downloadUrl = await getDownloadURL(myRef);
getStorage(app)
Gets the service for the default app or a given app.
getStorage() can be called with no arguments to access the default app's Storage service or as getStorage(app) to access the Storage service associated with a specific app.
Signature:
export declare function getStorage(app?: App): Storage;
Parameters
| Parameter | Type | Description |
|---|---|---|
| app | App |
Returns:
Example 1
// Get the Storage service for the default app
const defaultStorage = getStorage();
Example 2
// Get the Storage service for a given app
const otherStorage = getStorage(otherApp);
StorageErrorCode
The constant mapping for valid Storage client error codes.
Signature:
StorageErrorCode: {
readonly INVALID_ARGUMENT: "invalid-argument";
readonly INVALID_EMULATOR_HOST: "invalid-emulator-host";
readonly MISSING_DEPENDENCIES: "missing-dependencies";
readonly INVALID_CREDENTIAL: "invalid-credential";
readonly NO_DOWNLOAD_TOKEN: "no-download-token";
}
StorageErrorCode
The type definition for valid Storage client error codes.
Signature:
export type StorageErrorCode = typeof StorageErrorCode[keyof typeof StorageErrorCode];