Skip to content

Commit 12ddc18

Browse files
fix(storage): Type defs storage (#8387)
1 parent 068a924 commit 12ddc18

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

packages/storage/lib/modular/index.d.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import Task = FirebaseStorageTypes.Task;
2727
import ListOptions = FirebaseStorageTypes.ListOptions;
2828
import SettableMetadata = FirebaseStorageTypes.SettableMetadata;
2929
import EmulatorMockTokenOptions = FirebaseStorageTypes.EmulatorMockTokenOptions;
30+
import StringFormat = FirebaseStorageTypes.StringFormat;
3031
import FirebaseApp = ReactNativeFirebase.FirebaseApp;
3132

3233
export const StringFormat: FirebaseStorageTypes.StringFormat;
@@ -37,10 +38,11 @@ export const TaskState: FirebaseStorageTypes.TaskState;
3738
* Returns the existing default {@link Storage} instance that is associated with the
3839
* default {@link FirebaseApp}. The default storage bucket is used. If no instance exists, initializes a new
3940
* instance with default settings.
40-
*
41+
* @param app - Firebase app to get FirebaseStorage instance for.
42+
* @param bucketUrl - The gs:// url to your Firebase Storage Bucket. If not passed, uses the app's default Storage Bucket.
4143
* @returns The {@link Storage} instance of the provided app.
4244
*/
43-
export declare function getStorage(): Storage;
45+
export declare function getStorage(app?: FirebaseApp, bucketUrl?: string): Storage;
4446

4547
/**
4648
* Returns the existing default {@link Storage} instance that is associated with the
@@ -99,18 +101,22 @@ export function deleteObject(storageRef: Reference): Promise<void>;
99101
/**
100102
* Retrieves the blob at the given reference's location. Throws an error if the object is not found.
101103
* @param storageRef - The {@link Reference} to the object.
104+
* @param maxDownloadSizeBytes - Optional. Maximum size in bytes to retrieve.
102105
* @returns A promise resolving to the Blob.
103106
*/
104-
export function getBlob(storageRef: Reference): Promise<Blob>;
107+
export function getBlob(storageRef: Reference, maxDownloadSizeBytes?: number): Promise<Blob>;
105108

106109
/**
107110
* Retrieves bytes (up to the specified max size) from an object at the given reference's location.
108111
* Throws an error if the object is not found or if the size exceeds the maximum allowed.
109112
* @param storageRef - The {@link Reference} to the object.
110-
* @param maxDownloadSizeBytes - Maximum size in bytes to retrieve.
113+
* @param maxDownloadSizeBytes - Optional. Maximum size in bytes to retrieve.
111114
* @returns A promise resolving to an ArrayBuffer.
112115
*/
113-
export function getBytes(storageRef: Reference, maxDownloadSizeBytes: number): Promise<ArrayBuffer>;
116+
export function getBytes(
117+
storageRef: Reference,
118+
maxDownloadSizeBytes?: number,
119+
): Promise<ArrayBuffer>;
114120

115121
/**
116122
* Retrieves a long-lived download URL for the object at the given reference's location.
@@ -129,12 +135,12 @@ export function getMetadata(storageRef: Reference): Promise<FullMetadata>;
129135
/**
130136
* Retrieves a readable stream for the object at the given reference's location. This API is only available in Node.js.
131137
* @param storageRef - The {@link Reference} to the object.
132-
* @param maxDownloadSizeBytes - Maximum size in bytes to retrieve.
138+
* @param maxDownloadSizeBytes - Optional. Maximum size in bytes to retrieve.
133139
* @returns A NodeJS ReadableStream.
134140
*/
135141
export function getStream(
136142
storageRef: Reference,
137-
maxDownloadSizeBytes: number,
143+
maxDownloadSizeBytes?: number,
138144
): NodeJS.ReadableStream;
139145

140146
/**
@@ -200,7 +206,7 @@ export function uploadBytesResumable(
200206
export function uploadString(
201207
storageRef: Reference,
202208
data: string,
203-
format?: 'raw' | 'base64' | 'base64url' | 'data_url',
209+
format?: StringFormat,
204210
metadata?: SettableMetadata,
205211
): Task;
206212

packages/storage/lib/modular/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export function deleteObject(storageRef) {
9090
* @returns {Promise<Blob>}
9191
*/
9292
// eslint-disable-next-line
93-
export function getBlob(storageRef) {
93+
export function getBlob(storageRef, maxDownloadSizeBytes) {
9494
throw new Error('`getBlob()` is not implemented');
9595
}
9696

0 commit comments

Comments
 (0)