Skip to content

fix(storage): Type defs storage #8387

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions packages/storage/lib/modular/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import Task = FirebaseStorageTypes.Task;
import ListOptions = FirebaseStorageTypes.ListOptions;
import SettableMetadata = FirebaseStorageTypes.SettableMetadata;
import EmulatorMockTokenOptions = FirebaseStorageTypes.EmulatorMockTokenOptions;
import StringFormat = FirebaseStorageTypes.StringFormat;
import FirebaseApp = ReactNativeFirebase.FirebaseApp;

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

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

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

/**
* Retrieves a long-lived download URL for the object at the given reference's location.
Expand All @@ -129,12 +135,12 @@ export function getMetadata(storageRef: Reference): Promise<FullMetadata>;
/**
* Retrieves a readable stream for the object at the given reference's location. This API is only available in Node.js.
* @param storageRef - The {@link Reference} to the object.
* @param maxDownloadSizeBytes - Maximum size in bytes to retrieve.
* @param maxDownloadSizeBytes - Optional. Maximum size in bytes to retrieve.
* @returns A NodeJS ReadableStream.
*/
export function getStream(
storageRef: Reference,
maxDownloadSizeBytes: number,
maxDownloadSizeBytes?: number,
): NodeJS.ReadableStream;

/**
Expand Down Expand Up @@ -200,7 +206,7 @@ export function uploadBytesResumable(
export function uploadString(
storageRef: Reference,
data: string,
format?: 'raw' | 'base64' | 'base64url' | 'data_url',
format?: StringFormat,
metadata?: SettableMetadata,
): Task;

Expand Down
2 changes: 1 addition & 1 deletion packages/storage/lib/modular/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
* @returns {Promise<Blob>}
*/
// eslint-disable-next-line
export function getBlob(storageRef) {
export function getBlob(storageRef, maxDownloadSizeBytes) {

Check warning on line 93 in packages/storage/lib/modular/index.js

View check run for this annotation

Codecov / codecov/patch

packages/storage/lib/modular/index.js#L93

Added line #L93 was not covered by tests
throw new Error('`getBlob()` is not implemented');
}

Expand Down
Loading