UNPKG

@react-native-firebase/storage

Version:

React Native Firebase - React Native Firebase provides native integration with Cloud Storage, providing support to upload and download files directly from your device and from your Firebase Cloud Storage bucket.

152 lines 8.01 kB
import type { FirebaseApp } from '@react-native-firebase/app'; import './types/internal'; import type { EmulatorMockTokenOptions, FirebaseStorage, FullMetadata, ListOptions, ListResult, SettableMetadata, StorageReference, Task, UploadMetadata, UploadResult, UploadTask } from './types/storage'; export declare const SDK_VERSION = "26.1.0"; export declare function getStorage(app?: FirebaseApp, bucketUrl?: string): FirebaseStorage; export type * from './types/storage'; export { StringFormat, TaskEvent, TaskState } from './StorageStatics'; /** * Modify this Storage instance to communicate with the Firebase Storage emulator. * @param storage - Storage instance. * @param host - emulator host (e.g. - 'localhost') * @param port - emulator port (e.g. - 9199) * @param options - `EmulatorMockTokenOptions` instance. Optional. Web only. * @returns {void} */ export declare function connectStorageEmulator(storage: FirebaseStorage, host: string, port: number, options?: EmulatorMockTokenOptions): void; /** * Returns a StorageReference for the given URL or path in the default bucket. * @param storage - FirebaseStorage instance. * @param url - Optional gs:// or https:// URL, or path. If empty, returns root reference. * @returns {StorageReference} */ export declare function ref(storage: FirebaseStorage, url?: string): StorageReference; /** * Returns a StorageReference for the given path, or the same reference if path is omitted. * @param storageRef - StorageReference instance. * @param path - Optional child path. If omitted, returns the same reference. * @returns {StorageReference} */ export declare function ref(storageRef: StorageReference, path?: string): StorageReference; /** * Deletes the object at this reference's location. * @param storageRef - Storage `Reference` instance. * @returns {Promise<void>} */ export declare function deleteObject(storageRef: StorageReference): Promise<void>; /** * Downloads the data at the object's location. Returns an error if the object is not found. * @param _storageRef - Storage `Reference` instance. * @param _maxDownloadSizeBytes - The maximum allowed size in bytes to retrieve. Web only. * @returns {Promise<Blob>} */ export declare function getBlob(_storageRef: StorageReference, _maxDownloadSizeBytes?: number): Promise<Blob>; /** * Downloads the data at the object's location. Returns an error if the object is not found. * @param _storageRef - Storage `Reference` instance. * @param _maxDownloadSizeBytes - The maximum allowed size in bytes to retrieve. Web only. * @returns {Promise<ArrayBuffer>} */ export declare function getBytes(_storageRef: StorageReference, _maxDownloadSizeBytes?: number): Promise<ArrayBuffer>; /** * Deletes the object at this reference's location. * @param storageRef - Storage `Reference` instance. * @returns {Promise<string>} */ export declare function getDownloadURL(storageRef: StorageReference): Promise<string>; /** * Fetches metadata for the object at this location, if one exists. * @param storageRef - Storage `Reference` instance. * @returns {Promise<FullMetadata>} */ export declare function getMetadata(storageRef: StorageReference): Promise<FullMetadata>; /** * Downloads the data at the object's location. This API is only available in Nodejs. * @param _storageRef - Storage `Reference` instance. * @param _maxDownloadSizeBytes - The maximum allowed size in bytes to retrieve. Web only. * @returns {NodeJS.ReadableStream;} */ export declare function getStream(_storageRef: StorageReference, _maxDownloadSizeBytes?: number): NodeJS.ReadableStream; /** * List items (files) and prefixes (folders) under this storage reference * @param storageRef - Storage `Reference` instance. * @param options - Storage `ListOptions` instance. The options list() accepts. * @returns {Promise<ListResult>} */ export declare function list(storageRef: StorageReference, options?: ListOptions): Promise<ListResult>; /** * List all items (files) and prefixes (folders) under this storage reference. * @param storageRef - Storage `Reference` instance. * @returns {Promise<ListResult>} */ export declare function listAll(storageRef: StorageReference): Promise<ListResult>; /** * Updates the metadata for this object. * @param storageRef - Storage `Reference` instance. * @param metadata - A Storage `SettableMetadata` instance to update. * @returns {Promise<FullMetadata>} */ export declare function updateMetadata(storageRef: StorageReference, metadata: SettableMetadata): Promise<FullMetadata>; /** * Uploads data to this object's location. The upload is not resumable. * @param _storageRef - Storage `Reference` instance. * @param _data - The data (Blob | Uint8Array | ArrayBuffer) to upload to the storage bucket at the reference location. * @param _metadata - A Storage `UploadMetadata` instance to update. Optional. * @returns {Promise<UploadResult>} */ export declare function uploadBytes(_storageRef: StorageReference, _data: Blob | Uint8Array | ArrayBuffer, _metadata?: UploadMetadata): Promise<UploadResult>; /** * Uploads data to this object's location. The upload is not resumable. * @param storageRef - Storage `Reference` instance. * @param data - The data (Blob | Uint8Array | ArrayBuffer) to upload to the storage bucket at the reference location. * @param metadata - A Storage `UploadMetadata` instance to update. Optional. * @returns {UploadTask} */ export declare function uploadBytesResumable(storageRef: StorageReference, data: Blob | Uint8Array | ArrayBuffer, metadata?: UploadMetadata): UploadTask; /** * Uploads data to this object's location. The upload is not resumable. * @param storageRef - Storage `Reference` instance. * @param data - The string to upload. * @param format - The format of the string to upload ('raw' | 'base64' | 'base64url' | 'data_url'). Optional. * @param metadata - A Storage `UploadMetadata` instance to update. Optional. * @returns {Task} */ export declare function uploadString(storageRef: StorageReference, data: string, format?: 'raw' | 'base64' | 'base64url' | 'data_url', metadata?: UploadMetadata): Task; /** * Sets the maximum time in milliseconds to retry non-upload/download operations. * * @remarks React Native Firebase-specific modular helper. The firebase-js-sdk exposes this as a * writable property on the `FirebaseStorage` instance. **Android and iOS only.** */ export declare function setMaxOperationRetryTime(storage: FirebaseStorage, time: number): Promise<void>; /** * Sets the maximum time in milliseconds to retry an upload if a failure occurs. * * @remarks React Native Firebase-specific modular helper. The firebase-js-sdk exposes this as a * writable property on the `FirebaseStorage` instance. **Android and iOS only.** */ export declare function setMaxUploadRetryTime(storage: FirebaseStorage, time: number): Promise<void>; /** * Uploads a file from a local device path to Cloud Storage. * * @remarks React Native Firebase-specific API with **no firebase-js-sdk equivalent**. Use * `FilePath` from `@react-native-firebase/app` for portable device paths. **Native only** * — throws on Web interop. */ export declare function putFile(storageRef: StorageReference, filePath: string, metadata?: UploadMetadata): Task; /** * Downloads a Cloud Storage object to a local device file path. * * @remarks React Native Firebase-specific API with **no firebase-js-sdk equivalent**. Use * `FilePath` from `@react-native-firebase/app` for portable device paths. **Native only** * — throws on Web interop. */ export declare function writeToFile(storageRef: StorageReference, filePath: string): Task; /** * Sets the maximum time in milliseconds to retry a download if a failure occurs. * * @remarks React Native Firebase-specific modular helper with no direct firebase-js-sdk equivalent. * **Android and iOS only.** */ export declare function setMaxDownloadRetryTime(storage: FirebaseStorage, time: number): Promise<void>; //# sourceMappingURL=index.d.ts.map